Freshers PHP Technical Interview Questions & Answers

Question : What are the differences between Get and post methods in form submitting. Give the case where we can use get and we can use post methods? Answer : When to use GET or POST The HTML 2.0 specification says, in section Form Submission (and the HTML 4.0 specification repeats this with minor stylistic changes): –>If the processing of a form is idempotent (i.e. it has no lasting observable effect on the state of the world), then the form method should be GET. Many database searches have no visible side-effects and make ideal applications of query forms. – –>If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST. How the form data is transmitted? quotation from the HTML 4.0 specification –> If the method is ―get‖ – -, the user agent takes the value of action, appends a ? to it, then appends the form data set, encoded using the application/x-www-form-urlencoded content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes. –> If the method is ―post‖ –, the user agent conducts an HTTP post transaction using the value of the action attribute and a message created according to the content type specified by the enctype attribute. Quote from CGI FAQ Firstly, the the HTTP protocol specifies differing usages for the two methods. GET requests should always be idempotent on the server. This means that

whereas one GET request might (rarely) change some state on the Server, two or more identical requests will have no further effect. This is a theoretical point which is also good advice in practice. If a user hits ―reload‖ on his/her browser, an identical request will be sent to the server, potentially resulting in two identical database or guestbook entries, counter increments, etc. Browsers may reload a GET URL automatically, particularly if cacheing is disabled (as is usually the case with CGI output), but will typically prompt the user before re-submitting a POST request. This means you‘re far less likely to get inadvertently-repeated entries from POST. GET is (in theory) the preferred method for idempotent operations, such as querying a database, though it matters little if you‘re using a form. There is a further practical constraint that many systems have built-in limits to the length of a GET request they can handle: when the total size of a request (URL+params) approaches or exceeds 1Kb, you are well-advised to use POST in any case. I would prefer POST when I don‘t want the status to be change when user resubmits. And GET when it does not matter. Question : Who is the father of PHP and explain the changes in PHP versions? Answer : Rasmus Lerdorf is known as the father of PHP.PHP/FI 2.0 is an early and no longer supported version of PHP. PHP 3 is the successor to PHP/FI 2.0 and is a lot nicer. PHP 4 is the current generation of PHP, which uses the Zend engine under the hood. PHP 5 uses Zend engine 2 which, among other things, offers many additional OOPs features. Question : How can we submit a form without a submit button? Answer : The main idea behind this is to use Java script submit() function in order to submit the form without explicitly clicking any submit button. You can attach the document.formname.submit() method to onclick, onchange events of different inputs and perform the form submission. you

can even built a timer function where you can automatically submit the form after xx seconds once the loading is done (can be seen in online test sites). Question : In how many ways we can retrieve the data in the result set of MySQL using PHP? Answer : You can do it by 4 Ways 1. 2. 3. 4. mysql_fetch_row. mysql_fetch_array mysql_fetch_object mysql_fetch_assoc

Question : What is the difference between mysql_fetch_object and mysql_fetch_array? Answer : mysql_fetch_object() is similar to mysql_fetch_array(), with one difference an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names). Question : What is the difference between $message and $$message? Answer : It is a classic example of PHP‘s variable variables. take the following example. $message = ―Raghav‖; $$message = ―is a owner of http://sharag.wordpress.com/ ―; $message is a simple PHP variable that we are used to. But the $$message is not a very familiar face. It creates a variable name $mizan with the value ―is a moderator of PHPXperts.‖ assigned. break it like this${$message} => $mizanSometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.

the script will continue regardless. echo $found[1]. .cool@hotmail. etc. In other words.‘raghav.include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script. and you want to be sure that it is included exactly once to avoid problems with function redefinitions. variable value reassignments. Question : How can we create a database using PHP and MySQL? Answer : We can create MySQL Database with the use of mysql_create_db(―Database Name‖). use require() if you want a missing file to halt processing of the page.+)$/‖.$found).cool@hotmail. etc. include_once and require_once? Answer : The include() statement includes and evaluates the specified file.The documentation below also applies to require(). variable value reassignments. with the only difference being that if the code from a file has already been included. include() produces a Warning while require() results in a Fatal Error. and you want to be sure that it is included exactly once to avoid problems with function redefinitions. Question : What are the differences between require and include.+@(. it will not be included again. require_once()should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script. As the name suggests. include() does not behave this way.com‘.com „ from a string raghav. it will be included just once. This is a behavior similar to the include() statement. The include_once() statement includes and evaluates the specified file during the execution of the script.Question : How can we extract string „hotmail.com using regular expression of PHP? Answer : preg_match(‖/^http://. The two constructs are identical in every way except how they handle failure.

it may not execute properly in command line environment. Heap 3. POP3 AND LDAP? Answer : You can find these specific information in PHP Manual.23 and as a result if we do not specify the table name explicitly it will be assigned to the default engine.3.PHP”? Answer : Yes we can use include() more than one time in any page though it is not a very good practice. Question : Suppose your Zend engine supports the mode <? ?>. Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument.0.ename varchar(10)) ? Answer : Total 5 types of tables we can create 1. INNO DB 5. PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. Question : Functions in IMAP.PHP”) two times in a PHP page “makeit. Merge 4. ISAM MyISAM is the default storage engine as of MySQL 3. which type of table is generated when we are creating a table in the following syntax: create table employee (eno int(2). Question : What are the different tables present in MySQL. assuming ―php‖ is the command to invoke the CLI program. ―php myScript. Be aware that if your PHP script was written for the Web CGI interface. Then how can you configure your PHP Zend engine to support <?php ?>mode ? .php‖. Question : How can I execute a PHP script using command line? Answer : As of version 4. MyISAM 2. For example.Question : Can we use include (”abc.

etc. it worked as follows: . Question : Draw the architecture of Zend engine? Answer : The Zend Engine is the internal compiler and runtime engine used by PHP4.Answer : In php. For example: echo nl2br(‖god bless/n you‖) will output ―god bless you‖ to your browser. the Zend Engine is an abbreviation of their names.org/ Question : What is meant by nl2br()? Answer : Inserts HTML line breaks ( ) before all newlines in a string string nl2br (string).ini file: set short_open_tag=on to make PHP support Question : Shopping cart online validation i. Returns string with ‖ inserted before all newlines.e. how can we configure Paypal.? Answer : We can find the detail documentation about different paypal integration process at the following site PayPal PHP SDK : http://www.paypaldev. In the early days of PHP4. Developed by Zeev Suraski and Andi Gutmans.

PHP.com/downloads/mysql/.9 Note: visit http://www. all the shaded boxes are optional. The opcode was flushed from memory after execution. are low level binary instructions. PHP) instead of combination of other software programs. apache. there are a multitude of products and techniques to help you speed up this process. http://www.php. http://dev. PHP is more faster that asp or any other scripting language.2. PHP Scripts are loaded into memory and compiled into Zend opcodes.apache. we show the how modern PHP scripts work.2. Apache is a better server that IIS both in functionality and security. short for operation codes. Question : What are the reasons for selecting lamp (Linux. Opcodes. MySQL is world most popular open source database. and MySQL? Answer : As of Aug 2008 the current versions are PHP: php5. Then the opcode was executed and the HTML generated sent to the client.1. servers and operating systems? Answer : All of those are open source resource.net/.6 MySQL: MySQL 5.org/ to get current versions.2 Apache: Apache 2.mysql. Security of Linux is very very more than windows. In the following diagram. MySQL.The PHP script was loaded by the Zend Engine and compiled into Zend opcode. Question : What are the current versions of apache. .Today.

Question : How can we encrypt and decrypt a data present in a MySQL table using MySQL? Answer : AES_ENCRYPT () and AES_DECRYPT () Question : How can we encrypt the username and password using PHP? Answer : The functions in this section perform encryption and decryption, and compression and uncompression: Encryption AES_ENCRYT() ENCODE() DES_ENCRYPT() ENCRYPT() MD5() PASSWORD() SHA() or SHA1() Not available Decryption AES_DECRYPT() DECODE() DES_DECRYPT() Not available Not available Not available Not available UNCOMPRESSED_LENGTH()

OLD_PASSWORD() Not available

Question : What are the features and advantages of object-oriented programming? Answer : One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

Question : What are the differences between procedure-oriented languages and object-oriented languages? Answer : Traditional programming has the following characteristics:Functions are written sequentially, so that a change in programming can affect any code that follows it. If a function is used multiple times in a system (i.e., a piece of code that manages the date), it is often simply cut and pasted into each program (i.e., a change log, order function, fulfillment system, etc). If a date change is needed (i.e., Y2K when the code needed to be changed to handle four numerical digits instead of two), all these pieces of code must be found, modified, and tested. Code (sequences of computer instructions) and data (information on which the instructions operates on) are kept separate. Multiple sets of code can access and modify one set of data. One set of code may rely on data in multiple places. Multiple sets of code and data are required to work together. Changes made to any of the code sets and data sets can cause problems through out the system.Object-Oriented programming takes a radically different approach:Code and data are merged into one indivisible item – an object (the term ―component‖ has also been used to describe an object.) An object is an abstraction of a set of real-world things (for example, an object may be created around ―date‖) The object would contain all information and functionality for that thing (A date object it may contain labels like January, February, Tuesday, Wednesday. It may contain functionality that manages leap years, determines if it is a business day or a holiday, etc., See Fig. 1). Ideally, information about a particular thing should reside in only one place in a system.The information within an object is encapsulated (or hidden) from the rest of the system. A system is composed of multiple objects (i.e., date function, reports, order processing, etc., See Fig 2). When one object needs information from another object, a request is sent asking for specific information. (for example, a report object may need to know what today‘s date is and will send a request to the date object) These requests are called messages and each object has an interface that manages messages. OO programming languages include features such as ―class‖, ―instance‖, ―inheritance‖, and ―polymorphism‖ that increase the power and flexibility of an object.

Question : What is the use of friend function? Answer : Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class. A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match. Question : What are the differences between public, private, protected,static, transient, final and volatile? Answer : Public: Public declared items can be accessed everywhere. Protected: Protected limits access to inherited and parent classes (and to the class that defines the item). Private: Private limits visibility only to the class that defines the item. Static: A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope. Final: Final keyword prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended. Transient: A transient variable is a variable that may not be serialized. Volatile: a variable that might be concurrently modified by multiple threads should be declared volatile. Variables declared to be volatile will not be optimized by the compiler because their value can change at any time. Question : What are the different types of errors in PHP? Answer : Three are three types of errors:1. Notices: These are trivial, noncritical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although, as you will see, you can change this default behavior.2. Warnings: These are more serious errors – for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script

except with htmlentities(). This function is case-sensitive. instantiating an object of a non-existent class. and PHP‘s default behavior is to display them to the user when they take place. These errors cause the immediate termination of the script. returns FALSE. Question : How can we get second of the current time using date function? Answer : $second = date(‖s‖). use stristr(). If needle is not a string. PHP4 and PHP5 aer object oriented. For more details http://php.net/ Question : How can we convert asp pages to PHP pages? Answer : There are lots of tools available for asp to PHP conversion. Question : How can we convert the time zones using PHP? . you can search Google for that. Fatal errors: These are critical errors – for example. Question : What are the differences between PHP 3 and PHP 4 and PHP 5? Answer : PHP 3 is most procedure oriented and . the best one is available at http://asp2php.naken. Question : What is the functionality of the function strstr and stristr? Answer : strstr: Returns part of haystack string from the first occurrence of needle to the end of haystack. it is converted to an integer and applied as the ordinal value of a character.If needle is not found. or calling a non-existent function. For case-insensitive searches.cc/ Question : What is the functionality of the function htmlentities? Answer : Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways.termination.3. all characters which have HTML character entity equivalents are translated into these entities.

1. on Jan 1st. date(DATE_RFC1123. unset() makes a variable undefined. 2000 $stamp = mktime(8.‘ ‗. // Output the date in a standard format (RFC1123). ?> Question : What is meant by urlencode and urldecode? Answer : URLencode returns a string in which all non-alphanumeric characters except -_. that is the same way as in application/x-www-form-urlencoded media type. Question : How can we register the variables into a session? Answer : $_SESSION[‘name‘] = ―RAGHAV‖. // Now set the timezone back to US/Eastern date_default_timezone_set(‘US/Eastern‘). It is encoded the same way that the posted data from a WWW form is encoded. Question : What is the difference between the functions unlink and unset? Answer : unlink() deletes the given file from the file system. .1. this will print: // Fri. // Now generate the timestamp for that particular timezone. 31 Dec 1999 18:00:00 EST echo ‗ ‗.Answer : By using date_default_timezone_get and date_default_timezone_set function on PHP 5. 2000). urldecode decodes any %## encoding in the given string.0 <!–p// Discover what 8am in Tokyo relates to on the East Coast of the US // Set the default timezone to Tokyo time: date_default_timezone_set(‘Asia/Tokyo‘). 0. $stamp) . 1. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. 0.

-t. Maximum execution time of each script. in seconds Question : How can we take a backup of a MySQL table and how can we restore it. type.tbl_name…] FROM ‗/path/to/backup/directory‘mysqldump: Dumping Table Structure and DataUtility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server). –no-data Don‘t write any row information for the table. -d.tbl_name…] TO ‗/path/to/backup/directory‘ RESTORE TABLE tbl_name[.inimax_execution_time = 30. width. –no-create-info Don‘t write table creation information (the CREATE TABLE statement). ? Answer : To backup: BACKUP TABLE tbl_name[. and we can change the following setup at php. height) of an image using PHP image functions? Answer To know To know To know : To know the Image type use exif_imagetype () function the Image size use getimagesize () function the image width use imagesx () function the image height use imagesy() function Question : How can we get the browser properties using PHP? Answer : By using $_SERVER[‘HTTP_USER_AGENT‘] variable.iniupload_max_filesize = 2M Question : How can we increase the execution time of a PHP script? Answer : by changing the following setup at php.Question : How can we get the properties (size. This is very useful if you just want to get a dump of the structure for a table! . Question : What is the maximum size of a file that can be uploaded using PHP and how can we change this? Answer : By default the maximum size is 2MB. The dump will contain SQL statements to create the table and/or populate the table.

Question : How many ways can we get the value of current session id? Answer : session_id() returns the session id for the current session. •use limit keyword if you are looking for any specific number of rows from the result set. Question : How can we destroy the session. how can we unset the variable of a session? Answer : session_unregister — Unregister a global variable from the current session session_unset — Free all session variables Question : How can we destroy the cookie? Answer : Set the cookie in past. use select column1. .eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.Question : How can we optimize or increase the speed of a MySQL select query? Answer : • First of all instead of using select * from table1. Question : How many ways we can pass the variable through the navigation between the pages? Answer : •GET/QueryString •POST Question : What is the difference between ereg_replace() and eregi_replace()? Answer : eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters. column2. column3.. from table1 •Look for the opportunity to introduce index in the table you are querying.

rsort(). natsort(). Answer : Case Studio Smart Draw Question : How can I retrieve values from one database server and store themin other database server using PHP? . and uksort(). Question : List out some tools through which we can draw E-R diagrams for mysql. usort(). Question : How can I know that a variable is a number or not using a JavaScript? Answer : bool is_numeric ( mixed var) Returns TRUE if var is a number or a numeric string. natcasesort(). FALSE otherwise.Question : What are the different functions in sorting an array? Answer : Sort(). arsort(). asort(). Question : How can we know the count/number of elements of an array? Answer : 2 ways a) sizeof($urarray) This function is an alias of count() b) count($urarray) Question : What is the PHP predefined variable that tells the What types of images that PHP supports? Answer : Though i am not sure if this is wrong or not. With the exif extension you are able to work with image meta data. array_multisort(). ksort().or use isNaN(mixed var)The isNaN() function is used to check if a value is not a number.

$db1).Answer : WeWe can always fetch from one database and rewrite to another. mysql_select_db(‖db2?.‖user‖.‖pwd‖). $res2 = mysql_query(‖query‖. i. //this will failSo how to solve that? take a look below. $db2). $db1 = mysql_connect(‖host‖. $res2 = mysql_query(‖query‖. mysql_select_db(‖db1?. so both link willremain live.$db1). mysql_select_db(‖db2?. Here is a nice solution of it. even if yousupply the link as because the link was overwritten by the new db. Question : List out the predefined classes in PHP? Answer : Directory stdClass __PHP_Incomplete_Class exception php_user_filter Question : How can I make a script that can be bi-language (supports English.e $res1 – But you cannot execute new query in $db1.$db1). So mysql_connect has another optional boolean parameter whichindicates whether a link will be created or not.$db2).‖user‖. $db2 = mysql_connect(‖host‖. As we connect to the $db2 with this optional parameter set to ‗true‘.$db2).‖user‖.$db1).‖user‖. All the labels are putted in both language files as variables and . $db2 = mysql_connect(‖host‖.‖pwd‖). $res1 = mysql_query(‖query‖. mysql_select_db(‖db1?.so at this point the following script will fail $res3 = mysql_query(‖query‖. $res1 = mysql_query(‖query‖. $res3 = mysql_query(‖query‖. German)? Answer : You can maintain two separate language file for each of the language. $db2). At this point you can only fetch records from you previous ResultSet. $db1 = mysql_connect(‖host‖. Now the following query will execute successfully. true).‖pwd‖.$db1).‖pwd‖). $db1).

indexes? Answer : A stored procedure is a set of SQL commands that can be compiled andstored in the server.[Extended]. Question : What are the difference between abstract class and interface? Answer : Abstract class: abstract classes are the class where one or moremethods are abstract but not necessarily all method has to be abstract. clients don‘t need tokeep re-issuing the entire query but can refer to the stored procedure. [TABLENAME. You can also raise the conceptual level by . Interface: Interfaces are one type of class where all the methods are abstract. triggers. Question : How can we repair a MySQL table? Answer : The syntex for repairing a MySQL table is REPAIR TABLENAME. which are declare in its class but not defined. and less information needs to be sent between theserver and the client. The definition of those methods must be in its extending class.assign those variables in the PHP source. [Quick]. Question : What are the advantages of stored procedures. All the methods must be defined by its implemented class. ]. Abstract methods are the methods. this requires the client to approve it. On run-time choose the required language option. As a result we can not send mails usingJavaScript. Once this has been done.This command will repair the table specified if the quick is given the MySQL will do a repair of only the index tree if the extended is givenit will create index row by row.This provides better overall performance because the query has to beparsed only once. But we can call the client side mail protocol mailtovia JavaScript to prompt for an Email to send. That means all the methods only declared but not defined. Question : How can we send mail using JavaScript? Answer : JavaScript does not have any networking capabilities as it isdesigned to work on client site.

The larger the table. the more this costs. If the table has an index for the columns in question. database name and field name in MySQL? Answer : The following table describes the maximum length for each type of identifier. A trigger is effectively a type of stored procedure. However.000 rows.Without an index.Indexes are used to find rows with specific column values quickly.Triggers will also be implemented. Question : What is the maximum length of a table name. Identifier Maximum Length(bytes) Database 64 Table Column Index Alias 64 64 64 255 There are some restrictions on the characters that may appear in identifiers. as more of the work is done on the server side and less on the client (application)side. this is at least 100 times faster than reading sequentially. you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted.For example. Question : How many values can the SET function of MySQL take? Answer : MySQL set can take zero or more values but at the maximum it can take 64 values. If a table has 1. MySQL must begin with the first row and then read through the entire table to find the relevant rows. MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If you need to access most of the rows.havinglibraries of functions in the server. because this minimizes disk seeks. it is faster to read sequentially. stored procedures ofcourse do increase the load on the database server system. . one that is invoked when a particular event occurs.

The files have names that begin with the table name and have an extension to indicate the file type.The data file has a ‗.23.myd 3) . With this larger allowed table size. not by MySQL internal limits. If the time required to open a file in the directory increases significantly as the number of files increases.The following table lists some examples of operating .The ‗. what are they? Answer : The ‗.The data file has a ‗. The maximum table space size is 64TB.Question : What are the other commands to know the structure of table using MySQL commands except explain command? Answer : describe Table-Name.MySQL 3.MYI‘ (MYIndex) extension.MYD‘ (MYData) extension.The amount of available disk space limits the number of tables. database performance can be adversely affected.The index file has a ‗. the maximum table size was increased to65536 terabytes (2567 – 1 bytes).frm‘ file stores the table definition. MySQL is bound by that constraint.MYI‘ (MYIndex) extension. The table space can include raw disk partitions.The InnoDB storage engine maintains InnoDB tables within a table space that can be created from several files.myi? What do these files contain? Answer : In MySql.22 had a 4GB (4 gigabyte) limit on table size.The efficiency of the operating system in handling large numbers offiles in a directory can place a practical limit on the number of tables in a database.frm‘ file stores the table definition.MYD‘ (MYData) extension.the maximum effective table size for MySQL databases is usually determined by operating system constraints on file sizes. Question : What is the purpose of the following files having extensions 1) .frm2) . With the MyISAM storage engine in MySQL 3. Question : How many tables will create when we create table. the default table type is MyISAM. This allows a table to exceed the maximum individual file size.Each MyISAM table is stored on disk in three files. Question : What is maximum size of a database in MySQL? Answer : If the operating system or file system places a limit on the number of files in a directory. which allows extremely large tables.The index file has a ‗.

select.* or some specificdatabase by database. the *. update and delete etc. select.2-Intel 32-bit 2GB (LFS: 4GB) Linux 2. username@hostname and username@% where hostname is any valid hostname and % represents any name.system file-size limits. We want to ensure that there is no duplication of data in a given row. be sure to check the documentationspecific to your operating system.Operating System File-size Limit Linux 2.For the most up-to-date information. drop.*any condition password is simply the password of user. We can grant rights on all databse by using *.table_name username@hotsname can be either username@localhost.*any condition Question : Explain Normalization concept? Answer : The normalization process involves getting our data to conform to three progressive normal forms. but the last two are mainly academic and will not be discussed). This is only a rough guide and is not intended to be definitive. insert. the *.username@hotsname can be either username@localhost.* or a specific table by database.First Normal Form The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows.4+ (using ext3 filesystem) 4TB Solaris 9/10 16TB NetWare w/NSS filesystem 8TB Win32 w/ FAT/FAT32 2GB/4GB Win32 w/ NTFS 2TB (possibly larger) MacOS X w/ HFS+ 2TB Question : Give the syntax of Grant and Revoke commands? Answer : The generic syntax for grant is as following : > GRANT [rights] on [database/s] TO [username@hostname] IDENTIFIED BY[password]now rights can be a) All privileges b) combination of create. drop. The generic syntax for revoke is as following : > REVOKE [rights] on [database/s] FROM [username@hostname] now rights can be as explained above a) All privileges b) combination of create. and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms. username@hostname and username@% where hostname is any valid hostname and % represents any name. insert. and that every column stores . update and delete etc.

$db_link). I do not often use Third Normal Form. CURRENT_DATE() = CURDATE() for time use SELECT CURTIME(). the normal forms are progressive. but dependent on another value in the table. In Third Normal Form we are looking for data in our tables that is not fully dependent on the primary key. echo ―$num_rows rows found‖. $num_rows = mysql_num_rows($result). your tables must already be in First Normal Form. As stated earlier. Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. Question : How can we find the number of rows in a result set using PHP? Answer : $result = mysql_query($sql.Third Normal Form I have a confession to make. Question : How can we find the number of rows in a table using MySQL? Answer : Use this for mysql>SELECT COUNT(*) FROM table_name. CURRENT_TIME() = CURTIME() Question : What are the advantages and disadvantages of Cascading Style Sheets? Answer : External Style Sheets Advantages : Can control styles for multiple documents at once. Classes can be created for use on multiple HTML element types in many . Second Normal Form Where the First Normal Form deals with redundancy of data across a horizontal row. so to achieve Second Normal Form.the least amount of information possible (making the field atomic). Question : How many ways we can we find the current date using MySQL? Answer : SELECT CURDATE().

Selector grouping methods can not beused to create complex element addressing scenarios Question : What type of inheritance that PHP supports? Answer : In PHP an extended class is always dependent on a single base class.documents. Classes are extended using the keyword ‗extends‘. Disadvantages : This method can not control styles for multiple documents at once. Unique Key: Unique Keys are used to uniquely identify each row in thetable.Author can not create or control classes of elements to control multipleelement types within the document. Can not control styles for multiple documents at once. No additional downloads necessary to receive style information. Inline Styles Advantages : Useful for small quantities of style definitions. Disadvantages : Does not distance style information from content (a main goal ofSGML/HTML).that is.There can be only one primary key for a table but there can be morethan one unique for a table. A primary key value cannot be NULL. So NULL can be a unique key.Selector and grouping methods can be used to apply styles under complex contexts. Disadvantages : An extra download is required to import style information for eachdocument The rendering of the document may be delayed until the externalstyle sheet is loaded becomes slightly unwieldy for small quantities ofstyle definitions. Can override otherstyle specification methods at the local level so only exceptions needto be listed in conjunction with other style methods. . multiple inheritance is supported by interfaces. Question : What is the difference between Primary Key and Unique key? Answer : Primary Key: A column in a table whose values uniquely identify therows in the table.Selector and grouping methods can be used to apply styles under complexcontexts. There can be one and only one row for each unique key value. Embedded Style Sheets Advantages : Classes can be created for use on multiple tag types in the document.

[col2]. 1000. Question : What are the advantages/disadvantages of MySQL and PHP? Answer : Both of them are open source software (so free of cost). If two rows will have the same value in col1it will try to sort them according to col2 and so on. Tells DBMS according to what columns it should sort the result.[coln]. php is faster then ASP and JSP. sum all values or view average. SUM(col1). Question : What is the difference between char and varchar data types? Answer : Set char to occupy n bytes and it will take n bytes even if u r storing a value of n-m bytes Set varchar to occupy n bytes and it will take only the required space and will not use the n bytes eg. supportcross platform.[coln]. if you want to count all items in group. name char(15) will waste 10 bytes if we store ‗mizan‘.Condition2: Delete the last row(having the field value 999) andinsert another row then.GROUP BY[col1].Question : The structure of table view buyers is as follows: Field userid Type Null Key Default Extra PRI null null auto_increment user_pri_id int(15) varchar(10) YES the value of user_pri_id the last row 999 then What will happen inthe following conditions?Condition1: Delete all the rows and insert another row then.…. AVG(col1) with it. What is the value for this auto incremented field user_pri_id. name . You can use COUNT(col1). Tells DBMS to group results with same value of column col1.e. if each char takes a byte eg.[col2]. Answer : In both cases let the value for auto increment field be n then nextrow will have value n+1 i. Question : What is the difference between GROUP BY and ORDER BY in Sql? Answer : ORDER BY [col1].What is the starting value for this auto incremented field user_pri_id .….

Question : How can we know the number of days between two given dates using MySQL? Answer : SELECT DATEDIFF(‘2007-03-07?. Question : How can we know the number of days between two given dates using PHP? Answer : $date1 = date(‘Y-m-d‘). if each char takes a byte. but you have to make sure thata) data is delimitedb) columns and data matched correctly. Question : What is the functionality of md5 function in PHP? Answer : Calculate the md5 hash of a string.varchar(15) will just use 5 bytes if we store ‗mizan‘. rest 10 bytes will be free. syntax to load datafrom a text file. If I add random no techniques to it the md5 generated nowwill be totally different for the same string I am using.‘2005-01-01?). $days = (strtotime($date1) – strtotime($date2)) / (60 * 60 * 24). $date2 = ‗2006-08-15?. I use it to generate keys which I use to identifyusers etc. Question : How can I load data from a text file into a table? Answer : you can use LOAD DATA INFILE file_name. MNC php interview questions and answers 1) what is PHP? session_set_save_handler() session_set_save_handler sets the user-level session in storage . The hash is a 32characterhexadecimal number.

the Garbage Collection process will ignore it. If you opt to save your sessions in a different directory.gc_divisor default 1440 seconds or 24 minutes 1 100 3) PHP how to know user has read the email? Using DispositionNotification-To: in mailheader we can get read receipt.e. which is /tmp. it then analyzes any files in the /tmp for any session files that have not been accessed in a certain amount of time and physically deletes them. it deletes ALL files that have not been accessed in the directory. If the process is run.gc_maxlifetime session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. which deal with the garbage collector: PHP ini value name session.functions which are used for storing and retrieving data associated with a session. 2) what is garbage collection? default time ? refresh time? Garbage Collection is an automated part of PHP . at ‗createHeader‘ function add: . Storing the session data in a local database. There are 3 PHP. i.ini variables.php.gc_probability session. And then. This is especially important note on shared web servers. just edit email. and add this at vars definitions: var $readReceipt = null. the Garbage Collection process does not differentiate between which sessions belong to whom when run. If the Garbage Collection process runs. It‘s quite straightforward. arbage Collection process only runs in the default session save directory. Add the possibility to define a read receipt when sending an email.

This works on both built-in extensions and dynamically loaded ones (either through php.ini or dl()). $this>_newLine. 5) what is XML-RPC ? XML-RPC is a remote procedure call protocol which uses XML to encode its calls and HTTP as a transport mechanism. 7) default session save path ? Default session save path id temporary folder /tmp 8) What is the htmlspecialchars()? difference between htmlentities() and htmlspecialchars() – Convert some special characters to HTML entities (Only the most widely used) htmlentities() – Convert ALL special characters to HTML entities 9) how to do session using DB? . bool extension_loaded ( string $name ) — Find out whether an extension is loaded Warning :This function has been removed from some SAPI‘s in PHP 5. The body of the request is in XML. A procedure executes on the server and the value it returns is also formatted in XML. An XMLRPC message is an HTTP-POST request. $this->__formatAddress($this->readReceipt) . Use extension_loaded() to test whether a given extension is already available or not.= ‗DispositionNotification-To: ‗ . } 4) Runtime library loading ? without default mysql support.if (!empty($this->readReceipt)) { $this->__header . 6) default session time ? default session time in PHP is 1440 seconds or 24 minutes.3. how to run mysql with php? dl — Loads a PHP extension at runtime int dl ( string $library ) Loads the PHP extension given by the parameter library .

array( &$this. callback $read . ―gc‖ ) ). callback $gc ) using this function we can store sessions in DB. array( &$this. callback $close . array( &$this. ―read‖ ). ―open‖ ). return true. function SessionManager() { // Read the maxlifetime setting get_cfg_var(―session. array( &$this. array( &$this. $session_name ) { global $sess_save_path. callback $destroy .bool session_set_save_handler ( callback $open . // Don‘t need to do anything.gc_maxlifetime‖). } function open( $save_path. ―write‖). by overriding the default functions using session_set_save_handler handle we can store session in Db like below example class SessionManager { var $life_time. The function session_set_save_handler() lets the programmer specify which functions should actually be called when it is time to read or write session information. Just return TRUE. PHP has a built-in ability to override its default session handling. callback $write . from PHP $this->life_time = // Register this object as the session handler session_set_save_handler( array( &$this. ―destroy‖). } function close() { . ―close‖ ). $sess_save_path = $save_path.

$a = db_num_rows($rs). } function write( $id. $time)‖. return TRUE. mysql_real_escape_string($data). $newid = mysql_real_escape_string($id). $sql = ―SELECT `session_data` FROM `sessions` WHERE `session_id` = ‗$newid‘ AND `expires` > $time‖. $rs = db_query($sql). } . if($a > 0) { $row = db_fetch_assoc($rs).`expires`) VALUES(‗$newid‘. $data = $row['session_data']. } function read( $id ) { // Set empty result $data = ‖.return true.`session_data`. } return $data. // Fetch session data from the selected database $time = time(). $newdata = $sql = ―REPLACE `sessions` (`session_id`. ‗$newdata‘. $rs = db_query($sql). $newid = mysql_real_escape_string($id). $data ) { // Build query $time = time() + $this->life_time.

.‘.and store it in a DB with a active flag while log out or . $sql = ―DELETE FROM `sessions` WHERE `session_id` = ‗$newid‘‖. This behaviour can be changed in the php.cookie_lifetime = 0 to a value in seconds. userID etc. } function gc() { // Garbage Collection // Build DELETE query. Delete all records who have passed the expiration time $sql = ‗DELETE FROM `sessions` WHERE `expires` < UNIX_TIMESTAMP(). } } 10) how to track user logged out or not? when user is idle ? By checking the session variable exist or not while loading th page. 11) how to track no of user logged in ? whenever a user logs in track the IP.cookie_lifetime = 300 and restart your httpd server. As the session will exist longer as till browser closes. db_query($sql).function destroy( $id ) { // Build query $newid = mysql_real_escape_string($id).ini file by altering the line session. db_query($sql). return TRUE. If you wanted the session to finish in 5 minutes you would set this to session. // Always return TRUE return true. The default behaviour for sessions is to keep a session open indefinitely and only to expire a session when the browser is closed.

It allows only the relevant information to the user without revealing the functional mechanism through which a particular class had functioned. Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. . PDFlib offers an object-oriented API for PHP 5 in addition to the function-oriented API for PHP 4. FPDF requires no extension (except zlib to activate compression and GD for GIF support) and works with PHP4 and PHP5. Abstract class is a template class that contains such things as variable declarations and methods. Abstract methods are the methods. At any time by counting the no: of active records we can get the no: of visitors. encapsulation. 12) in PHP for pdf which library used? The PDF functions in PHP can create PDF files using the PDFlib library With version 6. polymorphism and inheritance.sesion expire make it inactive. Encapsulation passes the message without revealing the exact functional details of the class. GD and PHP may also require other libraries. depending on which image formats you want to work with. The definition of those methods must be in its extending class. FPDF is a PHP class which allows to generate PDF files with pure PHP. but cannot contain code for creating new instances. 14) what is oops? encapsulation? abstract class? interface? Object oriented programming language allows concepts such as modularity. There is also the » Panda module. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. A class that contains one or more methods that are declared but not implemented and defined as abstract. that is to say without using the PDFlib library. 13) for image work which library? You will need to compile PHP with the GD library of image functions for this to work. which are declare in its class but not define.

That means all the methods only declared but not defined. __construct All magic methods needs to be declared as public To use magic method they should be defined within the class or program scope Various Magic Methods used in PHP 5 are: __construct() __destruct() __set() __get() __call() __toString() __sleep() __wakeup() __isset() __unset() __autoload() __clone() 17) what is magic quotes? Magic Quotes is a process that automagically escapes incoming data to the PHP script.0 and REMOVED as of PHP 6.Interface: Interfaces are one type of class where all the methods are abstract. Overloading of methods through the __call function 4. Relying on this feature is highly discouraged. All the methods must be define by its implemented class. Eg.0. Full constructors and destructors etc through a __constuctor and __destructor function . The Singleton design pattern allows many parts of a program to share a single resource without having to work out the details of the sharing themselves. 15) what is design pattern? singleton pattern? A design pattern is a general reusable solution to a commonly occurring problem in software design. This feature has been DEPRECATED as of PHP 5. 16) what are magic methods? Magic methods are the members functions that is available to all the instance of class Magic methods always starts with ―__‖. array or NULL 3. Type hinting which allows you to force the type of a specific argument as object.3. 18) diff b/w php4 & php5 ? In PHP5 1 Implementation of exceptions and exception handling 2.0. It‘s preferred to code with magic quotes off and to instead escape the data at runtime. as needed.

This has changed in PHP5 — all objects are now passed by reference. Fatal errors: These are critical errors – for example. but they do not result in script termination.5. but the diff b/w php4 & php5 is that in php4 everything was passed by value where as in php5 its by reference. And one more thing in introduction of __clone object in PHP5 for copying the object. __autoload function for dynamically including certain include files depending on the class you are trying to create. including objects. By default. 3. 7 Interfaces & Abstract Classes 8 Passed by Reference : In PHP4. 2. accessing a variable that has not yet been defined. or calling a non-existent function. attempting to include() a file which does not exist. Notices: These are trivial. You can also declare an entire class as final which prevents it from having any children at all. instantiating an object of a non-existent class. And also any value change in reference object changes the actucal value of object also. 9 An __clone method if you really want to duplicate an object 19) in php4 can you define a class? how to call class in php4? can you create object in php4? yes you can define class and can call class by creating object of that class. such errors are not displayed to the user at all – although you can change this default behaviour. These . 6 Finality : can now use the final keyword to indicate that a method cannot be overridden by a child. Warnings: These are more serious errors – for example. these errors are displayed to the user. 20) types of error? how to set error settings at run time? here are three basic types of runtime errors in PHP: 1. non-critical errors that PHP encounters while executing a script – for example. everything was passed by value. By default.

23) what is URL rewriting? Using URL rewriting we can convert dynamic URl to static URL Static URLs are known to be better than Dynamic URLs because of a number of reasons 1. along with this we can use URL rewriting in adding variables [cookies] to the URL to handle the sessions. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed 22) what is outerjoin? inner join? OUTER JOIN in SQL allows us to retrieve all values in a certain table regardless of whether these values are present in other tables An inner join requires each record in the two joined tables to have a matching record. Static URLs typically Rank better in Search Engines. SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. Examples of such code include HTML code and client-side scripts. Search Engines are known to index the content of dynamic pages a lot slower compared to static pages. 2. Static URLs are always more friendlier looking to the End Users. and PHP?s default behaviour is to display them to the user when they take place.errors cause the immediate termination of the script. An inner join essentially combines the records from two tables (A and B) based on a given join-predicate. 3. 24) what is the major php security hole? how to avoid? . by using ini_set function. 21) what is cross site scripting? SQL injection? Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users.

php extension. require.0 is designed to enable reliable. the model represents the information (the data) of the application.1. the view corresponds to elements of the user interface such as text. Never include. For protected areas. 26) what is MVC? why its been used? Model-view-controller (MVC) is an architectural pattern used in software engineering. 25) whether PHP supports Microsoft SQL server ? The SQL Server Driver for PHP v1. 2. or otherwise open a file with a filename based on user input. WHY ITS NEEDED IS 1 Modular separation of function 2 Easier to maintain 3 View-Controller separation means: A — Tweaking design (HTML) without altering code B — Web design staff can modify UI without understanding code 27) what is framework? how it works? what is advantage? In general. Successful use of the pattern isolates business logic from user interface considerations. use sessions or validate the login every time. using MSSQL or ODBC modules we can access Microsoft SQL server. If you don‘t want the file contents to be seen. a framework is a real or conceptual structure intended to serve as a support or guide for the building of something that expands the . scalable integration with SQL Server for PHP applications deployed on the Windows platform. without thoroughly checking it first. Be careful when using register_globals = ON It was originally designed to make programming in PHP easier (and that it did). You essentially give the malicious user the ability to execute any command he or she wishes! 3. 6. Never run unescaped queries 5. give the file a . In MVC. and the controller manages the communication of data and the business rules used to manipulate the data to and from the model. and so forth. but misuse of it often led to security holes 4. resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. The Driver for PHP is a PHP 5 extension that allows the reading and writing of SQL Server data from within PHP scripts. checkbox items. Be careful with eval() Placing user-inputted values into the eval() function can be extremely dangerous.

NTLM. SFTP. Negotiate. ‗file‘ => ‗@/home/user/test. gopher. ex: Uploading file <?php /* http://localhost/upload.structure into something useful. and user+password authentication. cookies. HTTP POST. cookies. supporting FTP. kerberos…). proxy tunneling and a busload of other useful tricks. . curl supports SSL certificates. FTP uploading. TFTP. user+password authentication (Basic. HTTP PUT. ftp. DICT. LDAPS and FILE. file. libcurl also supports HTTPS certificates. HTTP PUT. Digest. CURL allows you to connect and communicate to many different types of servers with many different types of protocols. HTTPS. proxies. libcurl currently supports the http. HTTP POST. SCP. HTTP form based upload. HTTP. FTPS.png‘). ‗http://localhost/upload. 29) HOW we can transfer files from one server to another server without web forms? using CURL we can transfer files from one server to another server. FTP uploading (this can also be done with PHP‘s ftp extension). print_r($_FILES).php: print_r($_POST). TELNET. telnet. Advantages : Consistent Programming Model Direct Support for Security Simplified Development Efforts Easy Application Deployment and Maintenance 28) what is CURL? CURL means Client URL Library curl is a command line tool for transferring files with URL syntax. dict. curl_setopt($ch. $data = array(‗name‘ => ‗Foo‘. and ldap protocols. LDAP. https.php&#8217. */ $ch = curl_init(). CURLOPT_URL. file transfer resume. proxies.). HTTP form based upload.

but we can do another workaround like placing a table in a DIV layer and setting the DIV css property to overflow:auto will do the trick. ?> output: 1). CURLOPT_POST. etc. and people in organizations of work and/or play) c) navigation (the process of moving through the mental models) d) interaction (all input-output sequences and means for conveying feedback) e) and appearance (visual. tasks. efficient. jobs. 31) how to increase session time in PHP ? In php. etc. acoustic. functions.) b) mental models (structure of data.gc_maxlifetime session. roles. CURLOPT_POSTFIELDS. verbal. images.png [type] => image/png [tmp_name] => /tmp/phpcpjNeQ [error] => 0 [size] => 279 ) ) 30) using CSS can we have a scroll to table? No table won't support scrolling of its data. curl_setopt($ch.ini by setting session. and humane. curl_exec($ch). and 32) what is UI? What are the five primary user-interface components? A user interface is a means for human beings to interact with computer-based "tools" and"messages". pleasing. $data).). sounds. One presumed goal is to make the user's experience productive.cookie_lifetime values we can change the session time in PHP.curl_setopt($ch. The primary components of UIs are a) metaphors (fundamental concepts communicated through words. Array ( [name] => Foo ) Array ( [file] => Array ( [name] => test. .

In Windows. In addition to an asterisk (*). The name Cron is in fact derived from the same word from which we get the word chronology. as opposed to an Apache module). which is a wildcard that allows any value. Upon employing this command. if we want to run a script every Tuesday morning at 8:15 AM. So. are numerical constants. You can find information on using vi here. right? Not so fast! If you try to run a PHP script in this manner. your crontab will not function properly.33) How can I set a cron and how can I execute it in Unix. # crontab This command ‗edits‘ the crontab. Linux. The easiest way to use crontab is via the crontab command. which means order of time. The syntax of this file is very important – if you get it wrong. nothing will happen (barring very special configurations that have PHP compiled as an executable. can also be used to execute a Web document such as a PHP file. it‘s called Scheduled Tasks. My version of Linux uses the text editor vi. with the exception of the command itself. . and windows? Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. the ranges permitted for each field are as follows: Minutes: 0-59 Hours: 0-23 Day_of_month: 1-31 Month: 1-12 Weekday: 0-6 We can also include multiple values for each entry. you will be able to enter the commands that you wish to run. command can be any shell command and. simply by separating each value with a comma. as we will see momentarily. our mycronjob file will contain the following content on a single line: 15 8 * * 2 /path/to/scriptname This all seems simple enough. The syntax of the file should be as follows: minutes hours day_of_month month day_of_week command All the variables.

example. This is what my crontab will look like: 0 4 * * 1.php file we created in the first part of this article. in order for PHP to be parsed.2. it needs to be passed through Apache.com/file.g.com/mailstock. You could execute the PHP by invoking wget on the URL to the page. including: • An unorthodox objectreferencing methodology • No means for setting the scope (public. If you‘re using an RPM-based system (e.example.php 34)Difference b/w OOPS concept in php4 and PHP5 ? version 4‘s object-oriented functionality was rather hobbled. the page needs to be called via a browser or other means of retrieving Web content. so it should be accessible via the Internet. abstract) of fields and methods • No standard convention for naming constructors • Absence of object destructors • Lack of an objectcloning feature • Lack of support for interfaces 35) Difference b/w MyISAM and InnoDB in MySQL? Ans: .4. let‘s go back to the mailstock. we can go ahead and set up our crontab to use 4:00. you might have to compensate for the time difference when setting this value. type the following: # wget help If you are greeted with a wget package identification. I‘ll assume that your server configuration includes wget. In other words.The reason is that. We saved it in our document root. it is installed in your system. Although the very basic premises of objectoriented programming (OOP) were offered in version 4. private. Remember that we wanted it to run at 4PM Eastern time.5 wget http://www. Redhat or Mandrake). several deficiencies existed.php Now. like so: # wget http://www. For our purposes. log in to shell. and send you your precious closing bell report? Since I‘m located in the Eastern timezone.3. To test your configuration. but if you live elsewhere. as is the case with most default configurations. protected.

foreign keys  InnoDB is for high volume. Change the Session Timeout Value // Change the session timeout value to 30 minutes ini_set(’session.  InnoDB has been designed for maximum performance when processing large data volumes  Even though MyISAM is faster than InnoDB  InnoDB supports transaction. the InnoDB storage engine maintains its own buffer pool for caching data and indexes in main memory.gc_maxlifetime’. which may consist of several files (or raw disk partitions). You can commit and rollback with InnoDB but with MyISAM once you issue a command it’s done  MyISAM does not support foreign keys where as InnoDB supports  Fully integrated with MySQL Server. for example. This is different from. To find out what the default (file-based-sessions) session timeout value on the server is you can view it through a ini_get command: // Get the current Session Timeout Value $currentTimeoutInSecs = ini_get(’session. high performance  use MyISAM if they need speed and InnoDB for data integrity. The big difference between MySQL Table Type MyISAM and InnoDB is that InnoDB supports transaction  InnoDB supports some newer features: Transactions. MyISAM tables where each table is stored using separate files. row-level locking. 30*60). .  36) how to set session tiem out at run time or how to extend the session timeout at runtime? Ans: Sometimes it is necessary to set the default timeout period for PHP.gc_maxlifetime’). InnoDB tables can be of any size even on operating systems where file size is limited to 2GB. InnoDB stores its tables and indexes in a tablespace.

Objects are said to be the most important part of object oriented language. You may need to check through the session management class and see if it is getting the session timeout value from the ini configuration or through a method parameter (with default). objects and a set of well defined interfaces to that data.Data Encapsulation and many more. etc. They were designed to facilitate and implement object . Tcl. modules. 4) Explain the meaning of object in object oriented programming? Languages which are called as object oriented almost implement everything in them as objects such as punctuations.e. It lacks implementation of polymorphism on message arguments which is a OOPs feature. polymorphism and inheritance. C#. OOP is the common abbreviation for Object-Oriented Programming. Ruby. Organize a program around its data (object)& set well define interface to that data. ECMA Script. characters. classes. Python. It may require a little hunting about. blocks. 3) Explain about UML? UML or unified modeling language is regarded to implement complete specifications and features of object oriented language. C++.Data Absraction. Perl. Popularity of these languages has increased considerably as they can solve complex problems with ease. prototypes. VB. 2) Name some languages which have object oriented language and characteristics? Some of the languages which have object oriented languages present in them are ABAP.If you have changed the sessions to be placed inside a Database occasionally implementations will specify the expiry manually. i. PHP OOPS Interview Questions & Answers 1) Explain what is object oriented programming language? Object oriented programming language allows concepts such as modularity. Concept revolves around making simulation programs around an object. OOps have many properties such as DataHiding. encapsulation. LISP.Inheritence. etc. Abstract design can be implemented in object oriented programming languages. PHP.

oriented methods. 5) Explain about message passing in object oriented programming? Message passing is a method by which an object sends data to another object or requests other object to invoke method. This is also known as interfacing. It acts like a messenger from one object to other object to convey specific instructions. 6) State about Java and its relation to Object oriented programming? Java is widely used and its share is increasing considerably which is partly due to its close resemblance to object oriented languages such as C++. Code written in Java can be transported to many different platforms without changing it. It implements virtual machine. 7) What are the problems faced by the developer using object oriented programming language? These are some of the problems faced by the developer using object oriented language they are: a) Object oriented uses design patterns which can be referred to as anything in general. b) Repeatable solution to a problem can cause concern and disagreements and it is one of the major problems in software design. 8 ) State some of the advantages of object oriented programming? Some of the advantages of object oriented programming are as follows: a) A clear modular structure can be obtained which can be used as a prototype and it will not reveal the mechanism behind the design. It does have a clear interface. b) Ease of maintenance and modification to the existing objects can be done with ease. c) A good framework is provided which facilitates in creating rich GUI applications. 9 ) Explain about inheritance in OOPS? Objects in one class can acquire properties of the objects in other classes by way of inheritance. Reusability which is a major factor is provided in object oriented programming which adds features to a class without modifying it. New class can be obtained from a class which is already present. 10) Explain about the relationship between object oriented programming and databases? Object oriented programming and relational database programming are

almost similar in software engineering. RDBMS will not store objects directly and that‘s where object oriented programming comes into play. Object relational mapping is one such solution. 11) Explain about a class in OOP? In Object oriented programming usage of class often occurs. A class defines the characteristics of an object and its behaviors. This defines the nature and functioning of a specified object to which it is assigned. Code for a class should be encapsulated. 12) Explain the usage of encapsulation? Encapsulation specifies the different classes which can use the members of an object. The main goal of encapsulation is to provide an interface to clients which decrease the dependency on those features and parts which are likely to change in future. This facilitates easy changes to the code and features. 13) Explain about abstraction? Abstraction can also be achieved through composition. It solves a complex problem by defining only those classes which are relevant to the problem and not involving the whole complex code into play. 14) Explain what a method is? A method will affect only a particular object to which it is specified. Methods are verbs meaning they define actions which a particular object will perform. It also defines various other characteristics of a particular object. 15) Name the different Creational patterns in OO design? There are three patterns of design out of which Creational patterns play an important role the various patterns described underneath this are: a) Factory pattern b) Single ton pattern c) Prototype pattern d) Abstract factory pattern e) Builder pattern 16) Explain about realistic modeling? As we live in a world of objects, it logically follows that the object oriented approach models the real world accurately. The object oriented approach allows you to identify entities as objects having attributes and behavior. 17) Explain about the analysis phase? The anlaysis or the object oriented analysis phase considers the system as a solution to a problem in its environment or domain. Developer concentrates

on obtaining as much information as possible about the problem. Critical requirements needs to be identified. ************************************************************* *********************************************** 1) Explain the rationale behind Object Oriented concepts? Object oriented concepts form the base of all modern programming languages. Understanding the basic concepts of object-orientation helps a developer to use various modern day programming languages, more effectively. 2) Explain about Object oriented programming? Object oriented programming is one of the most popular methodologies in software development. It offers a powerful model for creating computer programs. It speeds the program development process, improves maintenance and enhances reusability of programs. 3) Explain what is an object? An object is a combination of messages and data. Objects can receive and send messages and use messages to interact with each other. The messages contain information that is to be passed to the recipient object. 4) Explain the implementation phase with respect to OOP? The design phase is followed by OOP, which is the implementation phase. OOP provides specifications for writing programs in a programming language. During the implementation phase, programming is done as per the requirements gathered during the analysis and design phases. 5) Explain about the Design Phase? In the design phase, the developers of the system document their understanding of the system. Design generates the blue print of the system that is to be implemented. The first step in creating an object oriented design is the identification of classes and their relationships. 6) Explain about a class? Class describes the nature of a particular thing. Structure and modularity is provided by a Class in object oriented programming environment. Characteristics of the class should be understandable by an ordinary non programmer and it should also convey the meaning of the problem statement to him. Class acts like a blue print.

Values defined for a particular object define its State. 9) Explain about multiple inheritance? Inheritance involves inheriting characteristics from its parents also they can have their own characteristics. 14) Explain about overriding polymorphism? Overriding polymorphism is known to occur when a data type can perform . It makes different classes and objects to interact with each other thus making the problem to be solved automatically. A sub class can have characteristics from multiple parents and still can have its own characteristics. Instance of a particular object is created at runtime. It simplifies the problem by giving the class its specific class of inheritance. 8 ) Explain about inheritance? Inheritance revolves around the concept of inheriting knowledge and class attributes from the parent class. 13) Explain about polymorphism? Polymorphism helps a sub class to behave like a parent class. When an object belonging to different data types respond to methods which have a same name. It allows only the relevant information to the user without revealing the functional mechanism through which a particular class had functioned. the only condition being that those methods should perform different function. 10) Explain about encapsulation? Encapsulation passes the message without revealing the exact functional details of the class. 12) Explain the mechanism of composition? Composition helps to simplify a complex problem into an easier problem. It interacts with the problem by making different classes and objects to send a message to each other. 11) Explain about abstraction? Abstraction simplifies a complex problem to a simpler problem by specifying and modeling the class to the relevant problem scenario. In multiple inheritance a class can have characteristics from multiple parents or classes. Inheritance forms an important concept in object oriented programming. Instance of an object explains the relation ship between different elements. In general sense a sub class tries to acquire characteristics from a parent class and they can also have their own characteristics. Composition also helps in solving the problem to an extent.7) Explain about instance in object oriented programming? Every class and an object have an instance.

etc use OOP. try { var pageTracker = _gat.)._getTracker(―UA-1855756-5″). Languages such as Python. Ruby on rails. 17) What are all the languages which support OOP? There are several programming languages which are implementing OOP because of its close proximity to solve real life problems. Hence it can be used any number of times. } catch(err) {} PHP MySQL Interview Questions and Answers . 16) Explain about parametric polymorphism? Parametric polymorphism is supported by many object oriented languages and they are very important for object oriented techniques.&#8221. float addition etc. 15) Explain about object oriented databases? Object oriented databases are very popular such as relational database management systems.protocol) ? ―https://ssl. pageTracker.js‘ type=‘text/javascript‘%3E%3C/script%3E‖)). var gaJsHost = ((―https:‖ == document. PHP. These DBMS use object oriented languages to make the process easier. Coldfusion. In parametric polymorphism code is written without any specification for the type of data present. Ruby.location._trackPageview(). Overriding polymorphism is generally used in complex projects where the use of a parameter is more.write(unescape(―%3Cscript src=‘‖ + gaJsHost + ―googleanalytics. Perl. Still many languages prefer to use DOM based languages due to the ease in coding. Object oriented databases systems use specific structure through which they extract data and they combine the data for a specific output.com/ga. For example an addition operator can perform different functions such as addition.&#8221.different functions. : ―http://www. document.

PEAR also provides a command-line interface that can be used to automatically install ―packages‖ Answer2: PEAR is short for ―PHP Extension and Application Repository‖ and is pronounced just like the fruit.What‟s PHP The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. The PHP Extension Community Library (PECL). PHP is basically used for developing web based software applications. What is meant by PEAR in php? Answer1: PEAR is the next revolution in PHP. It eases installation by bringing an automated wizard. mailing lists and download mirrors to support the PHP/PEAR community PEAR is a community-driven project with the PEAR Group as the governing . PEAR is a framework and distribution system for reusable PHP components. The purpose of PEAR is to provide: A structured library of open-sourced code for PHP users A system for code distribution and package maintenance A standard style for code written in PHP The PHP Foundation Classes (PFC). What Is a Session? A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. This repository is bringing higher level programming to PHP. A web site. and packing the strength and experience of PHP users into a nicely organised OOP library. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.

. $$holder = ‗bob‘. What is the difference between $message and $$message? Anwser 1: $message is a simple variable whereas $$message is a reference variable. If QUICK is given. echo ―Number of days since ‘2006-07-01′: $days‖. MySQL will do a repair of only the index tree. $days = (strtotime() – strtotime()) / (60 * 60 * 24). Anwser 2: They are both variables. $date2 = ‘2006-07-01′. it will create index row by row. The project has been founded by Stig S.body. How can we know the number of days between two given dates using PHP? Simple arithmetic: $date1 = date(‗Y-m-d‘). Example: $user = ‗bob‘ is equivalent to $holder = ‗user‘. But $message is a variable with a fixed name. If EXTENDED is given. How can we repair a MySQL table? The syntex for repairing a mysql table is: REPAIR TABLE tablename REPAIR TABLE tablename QUICK REPAIR TABLE tablename EXTENDED This command will repair the table specified. Bakken in 1999 and quite a lot of people have joined the project since then.

$$message is the same as $var. include_once? Anwser 1: require_once() and include_once() are both the functions to include and evaluate the specified file only once. How do you define a constant? Via define() directive. For example. Persistent cookies are less secure because users can open cookie files see the cookie values. if $message contains ―var‖. But require() and include() will do it as many times they are asked to do. By default.   What does a special set of tags do in PHP? What does a special set of tags <?= and ?> do in PHP? The output is displayed directly to the browser. 100). like define (―MYCONSTANT‖. When the browser is closed. cookies are created as temporary cookies which stored only in the browser‘s memory. What are the differences between require and include. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:    Temporary cookies can not be used for tracking long-term information. . If the specified file is included previous to the present call occurrence.$$message is a variable who‘s name is stored in $message. temporary cookies will be erased. Temporary cookies are safer because no programs other than the browser can access them. it will not be done again. Persistent cookies can be used for tracking long-term information. What Is a Persistent Cookie? A persistent cookie is a cookie which is stored in a cookie file permanently on the browser‘s computer.

URL coding converts special characters into % signs followed by two hex digits. with the only difference being that if the code from a file has already been included. This is a behavior similar to the include() statement. variable value reassignments. require_once() does the same as include_once(). it will not be included again. it will not be included again. etc. Anwser 3: All three are used to an include file into the current page. but it calls a fatal error if file not exists. The include_once() statement includes and evaluates the specified file during the execution of the script. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors. Anwser 2: string urlencode(str) – Returns the URL encoded version of the input string. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). If the file is not present. require(). String values to be used in URL query string need to be URL encoded. This is a behavior similar to the include() statement. Anwser 4: File will not be included more than once. What is meant by urlencode and urldecode? Anwser 1: urlencode() returns the URL encoded version of the given string. while in include() does not. For example: urlencode(―10. This will prevent problems with function redefinitions. In the URL encoded version: . urldecode() returns the URL decoded version of the given string. with the only difference being that if the code from a file has already been included.00%‖) will return ―10%2E00%25″. It des not call a fatal error if file not exists. calls a fatal error.Anwser 2: The include_once() statement includes and evaluates the specified file during the execution of the script. URL encoded strings are safe to be used as part of URLs.

it will call the PHP script specified in the form action attribute to process them. $url = ―http://domain.. string urldecode(str) – Returns the original string of the input URL encoded string.     The $fieldName is the name used in the <INPUT TYPE=FILE.urlencode($discount). $_FILES[$fieldName]['error'] – The error code associated with this file upload. Space characters are converted to ―+‖ characters. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES.com/submit.Alphanumeric characters are maintained as is. What is the difference between mysql_fetch_object and mysql_fetch_array? . Uploaded file information is organized in $_FILES as a twodimensional array as:  $_FILES[$fieldName]['name'] – The Original file name on the browser system. echo $url. $_FILES[$fieldName]['tmp_name'] – The temporary filename of the file in which the uploaded file was stored on the server..php?disc=&#8221. How To Get the Uploaded File Information in the Receiving Script? Once the Web server received the uploaded file. You will get ―http://domain.com/submit. $_FILES[$fieldName]['size'] – The Number of bytes of the file content.php?disc=10%2E00%25&#8243. $_FILES[$fieldName]['type'] – The file type determined by the browser.00%‖. NAME=fieldName>. For example: $discount =‖10. Other non-alphanumeric characters are converted ―%‖ followed by two hex digits representing the converted character.

INNO DB 5. When you fire the above create query MySQL will create a MyISAM table. Look at the similar PHP interview questions for more numeric problems. How To Create a Table? .php‖. Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example? In this example it wouldn‘t matter.23. Be aware that if your PHP script was written for the Web CGI interface. assuming ―php‖ is the command to invoke the CLI program.000 mln dollars‖. What are the different tables present in MySQL? Which type of table is generated when we are creating a table in the following syntax: create table employee(eno int(2). For example. but it keeps coming up with a different number.ename varchar(10))? Total 5 types of tables we can create 1. I am trying to assign a variable the value of 0123. then you definitely need to use the braces. Heap 3. Merge 4. ―php myScript. it may not execute properly in command line environment. what‟s the problem? PHP Interpreter treats numbers beginning with 0 as octal. ISAM MyISAM is the default storage engine as of MySQL 3. MyISAM 2.000. since the variable is all by itself.MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array How can I execute a PHP script using command line? Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. but if you were to print something like ―{$a}.

…).\n‖). you will get something like this: Table fyi_links created. ―. if (mysql_query($sql. How do you pass a variable by value? . ―)‖. INSERT into user (password. Answer2 You can use the MySQL PASSWORD() function to encrypt username and password. $sql = ―CREATE TABLE fyi_links (― . ‖ id INTEGER NOT NULL‖ . …) VALUES (PASSWORD($password‖)). ―. you can run the CREATE TABLE statement as shown in the following sample script: <?php include ―mysql_connection. counts INTEGER‖ .php‖. How can we encrypt the username and password using PHP? Answer1 You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD(―Password‖).\n‖). } mysql_close($con). } else { print(―Table creation failed. For example. notes VARCHAR(1024)‖ . ―. ―. url VARCHAR(80) NOT NULL‖ . $con)) { print(―Table fyi_links created. time TIMESTAMP DEFAULT sysdate()‖ . ?> Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script.If you want to create a table.

For example: strstr(―user@example. return true.com‖. When are you supposed to use endif to end the conditional statement? When the original if was followed by : and then the code block without braces. string needle ) returns part of haystack string from the first occurrence of needle to the end of haystack. Here is an example: function myfunction(form) { tdata=document. But you can use JavaScript to execute a client side email program send the email using the ―mailto‖ code. like $a = &$b WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()? string strstr ( string haystack.com‖.myform.Just like in C++. } What is the functionality of the function strstr and stristr? strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. stristr() is idential to strstr() except that it is case insensitive. put an ampersand in front of it. stristr() is idential to strstr() except that it is case insensitive. What is the difference between ereg_replace() and eregi_replace()? . How can we send mail using JavaScript? No.value.com?subject=…‖.‖@‖) will return ―@example. There is no way to send emails directly using JavaScript. location=‖mailto:mailid@domain.tbox1. This function is case-sensitive.

What is the purpose of the following files having extensions: frm.com germany 5 MySQL. If the variable $a is equal to 5 and variable $b is equal to character a.frm‘ file stores the table definition.MYI‘ (MYIndex) extension. myd.com pakistan 8. The files have names that begin with the table name and have an extension to indicate the file type. PHPsupport. ? func_num_args() function returns the number of parameters passed in.com austria 9. PHPfreaks. How do I find out the number of parameters passed into function9. Each MyISAM table is stored on disk in three files.MYD‘ (MYData) extension. and myi? What these files contain? In MySQL.eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.net usa 4 PHPtalk. it‘s a reference to existing variable. what‟s the value of $$b? 5. The ‗.com sourthafrica 10.net russia . The index file has a ‗. PHPtalk.com usa 6 sureshbabu canada 7 PHPbuddy. The data file has a ‗. the default table type is MyISAM. Write a query for the following question The table tbl_sites contains the following data: ————————————— Userid sitename country ————————————— 1 sureshbabu indian 2 PHPprogrammer andhra 3 PHP.

com italy Write a select query that will be displayed the duplicated site name and how many times it is duplicated? … SELECT sitename.com:</p>‖).‖It‘s an average site.php?name=Guest&comment=$comment\‖>‖ . The script below shows how to use urlencode(): <?php print(―<html>‖).php?‘. sureshbabu australia 12. $comment = urlencode($comment). $comment = ‗I want to say: ―It\‘s a good site! :->‖‗. print(―<p>‖ .11.‘‖>‘ . .‖It‘s an excellent site!</a></p>‖). COUNT(*) AS NumOccurrences FROM tbl_sites GROUP BY sitename HAVING COUNT(*) > 1 How To Protect Special Characters in Query String? If you want to include special characters like spaces in the query string.‖ to submit comments about FYICenter. ?> Are objects passed by value or by reference? Everything is passed by value. $comment = ‗This visitor said: ―It\‘s an average site! :-(―‗. print(―</html>‖). you need to protect them by applying the urlencode() translation function.‘<a href=‖processing_forms. PHPtalk.</a></p>‖). sureshbabu nepal 13. print(―<p>Please click the links below‖ . $comment = urlencode($comment).$comment. print(―<p>‖ .‖<a href=\‖processing_forms.

You can see the output which you are sending in the address bar. say more then 100 character you can use POST method. TRUNCATE TABLE table_name – This will delete the data of the table. With the Post method. give the case where we can use GET and we can use POST methods? Anwser 1: When we submit a form. not containing ASCII characters. What are the differences between GET and POST methods in form submitting. the browser appends the data onto the URL. which has the GET method it displays pair of name/value used in the form at the address bar of the browser preceded by url. Once most important difference is when you are sending the form with GET method. but not the table definition. the data is sent as ―standard input.What are the differences between DROP a table and TRUNCATE a table? DROP TABLE table_name – This will delete the table and its data.‖ Major Difference . Post method doesn‘t display these values. Anwser 2: When you want to send short or small data. Anwser 3: What are ―GET‖ and ―POST‖? GET and POST are methods used to send data to the server: With the GET method. then you can use GET‖ Method. But for long data sending. Whereas if you send the form with POST‖ method then user can not see that information.

Anwser 5: When we submit a form.In simple words. values are sent through invisible standard input (notice . which has the GET method it pass value in the form of query string (set of name/value pair) and display along with URL. Anwser 6: .php.php by $_POST['username'] and $_POST['password']. With GET we can a small data submit from the form (a set of 255 character) whereas Post method doesn‘t display value with URL. values are sent through visible query string (notice . GET: we are submitting a form to login.php. when we do submit or similar action. In the post method the data will be available as data blocks and not as query string in case of get method. POST is assumed more secure and we can send lot more data than that of GET method is limited (they say Internet Explorer can take care of maximum 2083 character as a query string). in POST method data is sent by standard input (nothing shown in URL when posting while in GET method data is sent through query string. It passes value in the form of Object and we can submit large data from the form.php by $_GET['username'] and $_GET['password'].php) and is retrieved by login. POST: we are submitting a form to login. when we do submit or similar action. Ex: Assume we are logging in with username and password.php?username=…&password=… as URL when executing the script login. Anwser 4: In the get method the data made available to the action page ( where data is received ) by the URL so data can be seen in the address bar. Not advisable if you are sending login info like password etc./login.php) and is retrieved by login./login.

The $_POST array stores data submitted by the POST method. while __wakeup retrieves them. Internally. 3. these errors are displayed to the user. By default. Notices: These are trivial. and PHP‘s default behavior is to display them to the user when they take place. How do you call a constructor for a parent class? parent::constructor($value) WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP? Here are three basic types of runtime errors in PHP: 1. POST method is mostly used for submitting a large amount or sensitive data. 2. instantiating an object of a non-existent class. these variations are represented by twelve different error types What‟s the special meaning of __sleep and __wakeup? __sleep returns the array of all the variables than need to be saved. These errors cause the immediate termination of the script. such errors are not displayed to the user at all – although you can change this default behavior. Data submitted by the POST method will not be displayed anywhere on the browser. or calling a non-existent function. Fatal errors: These are critical errors – for example. The $_GET array stores data submitted by the GET method. How can we submit a form without a submit button? .On the server side. the main difference between GET and POST is where the submitted is stored. On the browser side. By default. Warnings: These are more serious errors – for example. but they do not result in script termination. accessing a variable that has not yet been defined. attempting to include() a file which does not exist. GET method is mostly used for submitting a small amount and less sensitive data. non-critical errors that PHP encounters while executing a script – for example. the difference is that data submitted by the GET method will be displayed in the browser‘s address field.

myform. there.com using regular expression of php? We can use the preg_match() function with "/.$data). but doesn‟t for two-dimensional array of mine? .*)$/". unless you specifically need variable substitution. unset() is a function for variable management.*@(. How can we extract string „abc.com". Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution. It will simply delete the file in context. print $str. It will make a variable undefined.com „ from a string http://info@abc."http://info@abc. How come the code works.‖>Submit Me</a> Why doesn‟t the following code print the newline properly? <?php $str = „Hello. What is the difference between the functions unlink and unset? unlink() is a function for file system handling.submit(). For example: preg_match("/.*)$/" as the regular expression pattern. For example: <a href=‖javascript: document.*@(. just as a sequence of two characters – \ and n. it‘s always a better idea speed-wise to initialize a string with single quotes.If you don‘t want to use the Submit button to submit a form. echo $data[1].\nHow are you?\nThanks for visiting fyicenter‟. But you need to use some JavaScript code in the URL of the link. you can use normal hyper links to submit a form. ?> Because inside the single quotes the \n character is not interpreted as newline.

Can we use include (“abc. In the JavaScript code. How can we register the variables into a session? session_register($session_var). there are echo. Explain the differences. How many ways we can retrieve the date in result set of mysql using php? As individual objects so single record or as a set or arrays. the second is hex 23. print ―Contents: {$arr[1][2]}‖ would‘ve worked.submit() function to submit the form.php”) two times in a php page “makeit.form. $_SESSION['var'] = ‗value‘. and just outputs the contents following the construct to the screen.form. print is also a construct (so parentheses are . echo is the most primitive of them. For example: <input type=button value=‖Save‖ onClick=‖document.Any time you have an array with more than one dimension. print and printf.php”? Yes.submit()‖> How can we create a database using PHP and mysql? We can create MySQL database with the use of mysql_create_db($databaseName) to create a database. What is the difference between characters 23 and \x23? The first one is octal 23. How can we submit form without a submit button? We can use a simple JavaScript code linked to an event trigger of any form field. complex parsing syntax is required. For printing out strings. we can call the document.

. >. ?> and it will output the string ―Welcome to fyicenter!‖ print does not take multiple parameters. It is also generally argued that echo is faster. What will be printed is FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS. ‗fyicenter!‘. it‘s worth using strtolower() first. double quote ‖ and ampersand. I am writing an application in PHP that outputs a printable version of driving directions. ‗ ‗. However. you can pass multiple parameters to echo. How do I accomplish that with PHP? On large strings that need to be formatted according to some length specifications. but usually the speed advantage is negligible. not a construct. but it returns TRUE on successful output and FALSE if it was unable to print out the string. What‟s the difference between htmlentities() and htmlspecialchars()? htmlspecialchars only takes care of <. but it‘s the slowest way to print out data out of echo. What‟s the output of the ucwords function in this example? $formatted = ucwords(―FYICENTER IS COLLECTION OF INTERVIEW QUESTIONS‖). It contains some long sentences. print $formatted. printf is a function.optional when calling it). htmlentities translates all occurrences of character sequences that have different meaning in HTML. like: <?php echo ‗Welcome ‗. ‗to‘. ucwords() makes every first letter of every word capital. print and printf. and allows such advantages as formatted output. To avoid this. and would like to make sure that no line exceeds 50 characters. use wordwrap() or chunk_split(). and I am a neat freak. and get a properly formatted string. and might not be there for future versions of PHP. single quote ‗. but it does not lower-case anything else.

com?subject=Feedback‖. So if md5() generates the most secure hash. not the first one. how can we unset the variable of a session? session_unregister() – Unregister a global variable from the current session session_unset() – Free all session variables What are the different functions in sorting an array? Sorting functions in PHP: asort() arsort() ksort() krsort() uksort() sort() natsort() rsort() . gives the match. but that doesn‘t mean it‘s free. $output[1].How can we extract string “abc. Second. the more secure the crypto is. if frequent md5() generation is required. echo $output[1]. Note that the second index of $output. How can we destroy the session.com?subject=Feedback” using regular expression of PHP? $text = ―mailto:info@abc. $text. $output). you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space.*@([^?]*)|‘.com” from a string “mailto:info@abc. the longer is the computation time to deliver the hash value. $output[0]. depending on the data that you‘re encrypting. First off. A high volume site might be significantly slowed down. why would you ever use the less secure crc32() and sha1()? Crypto usage in PHP is simple. preg_match(‗|.

a database name.How can we know the count/number of elements of an array? 2 ways: a) sizeof($array) – This function is an alias of count() b) count($urarray) – This function returns the number of elements in an array. What is the maximum length of a table name. and get it back from session in the next page. 2. and get it back from the form in the next page. and get it back from the cookie in the next page. Put the variable into a hidden form field. Interestingly if you just pass a simple var instead of an array. 3. Put the variable into cookie in the first page. count() will return 1. How many ways we can pass the variable through the navigation between the pages? At least 3 ways: 1. How can we find the number of rows in a table using MySQL? . Put the variable into session in the first page. or a field name in MySQL? Database name: 64 characters Table name: 64 characters Column name: 64 characters How many values can the SET function of MySQL take? MySQL SET function can take zero or more values. What are the other commands to know the structure of a table using MySQL commands except EXPLAIN command? DESCRIBE table_name. but at the maximum it can take 64 values.

UPDATE and DELETE etc. evidently. SELECT. How can we find the number of rows in a result set using PHP? Here is how can you find the number of rows in a result set in PHP: $result = mysql_query($any_valid_sql. DROP. CRC32 is. $database_link). We can grant rights on all databse by usingh *.table_name. How many ways we can we find the current date using MySQL? SELECT SELECT SELECT SELECT CURDATE(). INSERT.Use this for MySQL SELECT COUNT(*) FROM table_name.* or a specific table by database. CURRENT_TIME(). crc32() and sha1() crypto on PHP? The major difference is the length of the hash generated. Give the syntax of GRANT commands? The generic syntax for GRANT is as following GRANT [rights] on [database] TO [username@hostname] IDENTIFIED BY [password] Now rights can be: a) ALL privilages b) Combination of CREATE. while sha1() returns a 128 bit value. . This is important when avoiding collisions. echo ―$num_rows rows found‖. What‟s the difference between md5().* or some specific database by database. 32 bits. CURTIME(). and md5() returns a 160 bit value. CURRENT_DATE(). $num_rows = mysql_num_rows($result).

* or some specific database by database. SELECT.Give the syntax of REVOKE commands? The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privilages b) Combination of CREATE. DROP. What is the starting value for this auto incremented field user_pri_id? Condition 2: Delete the last row (having the field value 2345) and insert another row.table_name. Answer the questions with the following assumption The structure of table view buyers is as follows: +-------------+-------------+------+-----+---------+---------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+---------------+ | user_pri_id | int(15) | | PRI | NULL | auto_increment | | userid | varchar(10) | YES | | NULL | | +-------------+-------------+------+-----+---------+---------------+ The value of user_pri_id of the last row is 2345. UPDATE and DELETE etc.* or a specific table by database. We can grant rights on all databse by usingh *. What is the value for this auto incremented field user_pri_id? . What will happen in the following conditions? Condition 1: Delete all the rows and insert another row. INSERT.

internally PHP will cast everything to the integer type. For example. What is the functionality of MD5 function in PHP? string md5(string) It calculates the MD5 hash of a string. How can we encrypt and decrypt a data present in a mysql table using mysql? AES_ENCRYPT() and AES_DECRYPT() Will comparison of string “10″ and integer 11 work in PHP? Yes. For example. ―Hello!‖ will be stored as ―Hello! ‖ in CHAR(10) column. ―Hello!‖ will be stored as ―Hello!‖ in VARCHAR(10) column. VARCHAR is a variable length data type. so numbers 10 and 11 will be compared. How can I load data from a text file into a table? The MySQL provides a LOAD DATA INFILE command. The hash is a 32-character hexadecimal number. the value of this auto incremented field user_pri_id is 2346. What is the difference between CHAR and VARCHAR data types? CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. You can load data from a file.In both conditions. Great tool but you need to make sure that: a) Data must be delimited b) Data fields must match table columns correctly How can we know the number of days between two given dates using MySQL? . VARCHAR(n) will take only the required storage for the actual number of characters entered to that column.

sum all values or view average. GROUP BY [col1]. AVG(col1) with it.…[coln].Use DATEDIFF() SELECT DATEDIFF(NOW(). What is meant by MIME? Answer 1: MIME is Multipurpose Internet Mail Extensions is an Internet standard for the format of e-mail. if you want to count all items in group. The most general way to satisfy a GROUP BY clause is to scan the whole table and create a new temporary table where all rows from each group are consecutive.[col2]. Tells DBMS according to what columns it should sort the result. use an ORDER BY clause. However browsers also uses MIME standard to transmit files. When browser sees such header it shows the data as it would be a file (for example image) . MIME has a header which is added to a beginning of the data. ORDER BY [col1].…[coln]. Tells DBMS to group (aggregate) results with same value of column col1.‘2006-07-01′). You can use COUNT(col1). SUM(col1). and then use this temporary table to discover groups and apply aggregate functions (if any).[col2]. How can we change the name of a column of a table? This will change the name of column: ALTER TABLE table_name CHANGE old_colm_name new_colm_name How can we change the data type of a column of a table? This will change the data type of a column: ALTER TABLE table_name CHANGE colm_name same_colm_name [new data type] What is the difference between GROUP BY and ORDER BY in SQL? To sort a result. If two rows will hawe the same value in col1 it will try to sort them according to col2 and so on.

etc. … How can we know that a session is started or not? A session starts by session_start() function. $row['email']. etc. then is the session is exist to other windows or not? And if yes then why? If no then why? .). while the latter returns a the results an array containing both numeric and associative keys ($row['name']. This session_start() is always declared in header portion. it always declares first. etc. $row[1]. mysql_fetch_object().Some examples of MIME types: audio/x-ms-wmp image/png aplication/x-shockwave-flash Answer 2: Multipurpose Internet Mail Extensions. $row->email.). mysql_fetch_row() -> Fetch a result set as a regular array(). then we write session_register(). Answer 2: The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0]. mysql_fetch_row()? Answer 1: mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array. The standard provides for a system of registration of file types with information about the applications needed to process them.). This information is incorporated into Web server and browser software. WWW‘s ability to recognize and handle files of different types is largely dependent on the use of the MIME (Multipurpose Internet Mail Extensions) standard. mysql_fetch_object() returns an object ($row->name. If we login more than one browser windows at the same time with same user and after that we close one window. mysql_fetch_object() -> Fetch a result row as an object. What are the differences between mysql_fetch_array(). and enables the automatic recognition and display of registered file types.

myd Table structure is stored in name.PHP) two times in a PHP page makeit.Session depends on browser. The session data will be deleted after session time out.php What are the differences between mysql_fetch_array(). or FALSE if there are no more rows .PHP. Can we use include(abc.frm Index is stored in name. Returns an object with properties that correspond to the fetched row. means there should not be functions or classes or variables with the same name in abc. If connection is lost and you recreate connection. Error supporting is increased in PHP5. then session will continue in the browser. the file names are case-sensitive) there shouldn‘t be any duplicate function names. If browser is closed then session is lost. mysql_fetch_object().PHP and makeit. XML and SQLLite will is increased in PHP5. mysql_fetch_object – Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. PHP5 supports oops concepts and Zend engine 2 is used.myi What is the difference between PHP4 and PHP5? PHP4 cannot support oops concepts and Zend engine 1 is used. but here are some things to make sure of: (including abc. mysql_fetch_row()? mysql_fetch_array – Fetch a result row as an associative array and a numeric array. What are the MySQL database files stored in system ? Data is stored in name.PHP”? Yes we can include that many times we want.

Beta MySQL 5.1.0 IN HOW MANY WAYS WE CAN RETRIEVE DATA IN THE RESULT SET OF MYSQL USING PHP? . key_str) How can I retrieve values from one database server and store them in other database server using PHP? For this purpose. Each result column is stored in an array offset. you can first read the data from one server into session variables. The row is returned as an array. PHP 5. Then connect to other server and simply insert the data into the database. WHO IS THE FATHER OF PHP AND WHAT IS THE CURRENT VERSION OF PHP AND MYSQL? Rasmus Lerdorf. output: god bless<br> you How can we encrypt and decrypt a data presented in a table using MySQL? You can use functions: AES_ENCRYPT() and AES_DECRYPT() like: AES_ENCRYPT(str. key_str) AES_DECRYPT(crypt_str. starting at offset 0. echo nl2br(―god bless \n you‖).mysql_fetch_row() – Fetches one row of data from the result associated with the specified result identifier. What is meant by nl2br()? Anwser1: nl2br() inserts a HTML tag <br> before all new line characters \n in a string.

Get a result row as an enumerated array What are the functions for IMAP? imap_body – Read the message body imap_check – Check current mailbox imap_delete – Mark a message for deletion from current mailbox imap_mail – Send an email message What are encryption functions in PHP? CRYPT() MD5() What is the difference between htmlentities() and htmlspecialchars()? htmlspecialchars() – Convert some special characters to HTML entities (Only the most widely used) htmlentities() – Convert ALL special characters to HTML entities What is the functionality of the function htmlentities? htmlentities() – Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways. a numeric array. width. height) of an image using php image functions? To know the image size use getimagesize() function To know the image width use imagesx() function To know the image height use imagesy() function How can we increase the execution time of a php script? . type.mysql_fetch_array – Fetch a result row as an associative array. all characters which have HTML character entity equivalents are translated into these entities. How can we get the properties (size. or both mysql_fetch_assoc – Fetch a result row as an associative array mysql_fetch_object – Fetch a result row as an object mysql_fetch_row —. except with htmlentities().

HOW CAN WE TAKE A BACKUP OF A MYSQL TABLE AND HOW CAN WE RESTORE IT? Answer 1: Create a full backup of your database: shell> mysqldump tab=/path/to/some/dir opt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir The full backup file is just a set of SQL statements. -d. set_time_limit() restarts the timeout counter from zero. When called. The default limit is 30 seconds or. If this is reached. and 25 seconds into script execution a call such as set_time_limit(20) is made. no time limit is imposed. the script will run for a total of 45 seconds before timing out. -t. if the timeout is the default 30 seconds. If seconds is set to zero. no-create-info Don‘t write table creation information (the CREATE TABLE statement).‖Executed‖. In other words. if it exists. the script returns a fatal error. The dump will contain SQL statements to create the table and/or populate the table. so restoring it is very easy: shell> mysql ―. the max_execution_time value defined in the php. Answer 2: To backup: BACKUP TABLE tbl_name TO /path/to/backup/directory ‘ To restore: RESTORE TABLE tbl_name FROM /path/to/backup/directory mysqldump: Dumping Table Structure and Data Utility to dump a database or a collection of database for backup or for transferring the data to another SQL server (not necessarily a MySQL server).ini. no-data Don‘t write any row information for the table.By the use of void set_time_limit(int seconds) Set the number of seconds a script is allowed to run. This is very useful if you just want to get a dump of the structure for a table! .

variable – name of the cookie variable value – value of the cookie variable time – expiry time Example: setcookie(‗Test‘. This function returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP. else alert(‗Not an integer‘).time()-3600).$i. The following bits are returned. IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM.'value‘.'time‘) . // already expired time Reset a cookie by specifying its name only Example: setcookie(‗Test‘). Tools used for drawing ER diagrams. . Test – cookie variable name $i – value of the variable ‗Test‘ time()+3600 – denotes that the cookie will expire after an one hour How to reset/destroy a cookie Reset a cookie by specifying expire time in the past: Example: setcookie(‗Test‘.time()+3600).8. if(parseInt(myValue)== myValue) alert(‗Integer‘). imagetypes() – Returns the image types supported. CHECK IF A VARIABLE IS AN INTEGER IN JAVASCRIPT var myValue =9.$i.How to set cookies? setcookie(‗variable‘. WHAT TYPES OF IMAGES THAT PHP SUPPORTS? Using imagetypes() function to find out what types of images are supported in your PHP engine.

How can we destroy the cookie? Set the cookie with a past expiration time. FALSE otherwise. Syntax isNaN(number) Parameter Description number Required. This will submit the form.submit(). How many ways can we get the value of current session id? session_id() returns the session id for the current session. Answer 2: Definition and Usage The isNaN() function is used to check if a value is not a number. and MySQL? PHP: PHP 5.myform. The value to be tested How can we submit from without a submit button? Trigger the JavaScript code on any event ( like onSelect of drop down list box. etc ) document.1 Apache: Apache 2.Case Studio Smart Draw How can I know that a variable is a number or not using a JavaScript? Answer 1: bool is_numeric( mixed var) Returns TRUE if var is a number or a numeric string. What are the current versions of Apache.1 . onfocus. PHP.1.2 MySQL: MySQL 5.

Components that manage dates. an OO approach can speed development time since many objects are standard across systems and can be reused. Apache. MySQL. shipping. A friend declaration is essentially a prototype for a member function. by using a friend specifier in the class that is admitting them. Apache is a better server that IIS both in functionality and security. Such functions can be declared either as member functions of one class or as global functions. as if they were themselves members of that class. etc. Such functions can use all attributes of the class which names them as a friend. can be purchased and easily modified for a specific system. OO programming is also considered to be better at modeling the real world than is procedural programming. Mysql is world most popular open source database. but instead of requiring an implementation with the name of that class attached by the double colon syntax. shopping carts. What are the features and advantages of OBJECT ORIENTED PROGRAMMING? One of the main advantages of OO programming is its ease of modification. OO systems are also easier for nontechnical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. class mylinkage { . It allows for more complicated and flexible interactions. a global function or member function of another class provides the match. objects can easily be modified and added to a system there by reducing maintenance costs. What is the use of friend function? Friend functions Sometimes a function is best shared among a number of different classes.What are the reasons for selecting LAMP (Linux. For some systems. servers and operating systems? All of those are open source resource. Php) instead of combination of other software programs. Security of linux is very very more than windows. Php is more faster that asp or any other scripting language. In either case they can be set to be friends of other classes.

mylinkage * next. void set_next(mylinkage* L). protected: friend void set_prev(mylinkage* L. void mylinkage::set_next(mylinkage* L) { next = L.private: mylinkage * prev. class A { friend class B. This is particularly powerful when using the . }. Friend functions allow binary operators to be defined which combine private data in a pair of objects. public: mylinkage * succ(). class B { int f1(). by specifying the entire class as a friend. } void set_prev(mylinkage * L. mylinkage * N ) { N->prev = L. mylinkage * pred(). } Friends in other classes It is possible to specify a member function of another class as a friend as follows: class C { friend int B::f1(). mylinkage(). }. }. It is also possible to specify all the functions in another class as friends. }. mylinkage* N).

as more of the work is done on the server side and . stored procedures of course do increase the load on the database server system. However. What is the maximum size of a file that can be uploaded using PHP and how can we change this? You can change maximum size of a file set upload_max_filesize variable in php. What are the difference between abstract class and interface? Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. which are declare in its class but not define. What are the advantages of stored procedures. Abstract methods are the methods. indexes? A stored procedure is a set of SQL commands that can be compiled and stored in the server. clients don‘t need to keep reissuing the entire query but can refer to the stored procedure. You can also raise the conceptual level by having libraries of functions in the server. and less information needs to be sent between the server and the client. That means all the methods only declared but not defined. Interface: Interfaces are one type of class where all the methods are abstract. triggers. How can we get second of the current time using date function? $second = date(―s‖). Once this has been done. All the methods must be define by its implemented class.operator overloading features of C++. The definition of those methods must be in its extending class.ini file How can I make a script that can be bilingual (supports English. This provides better overall performance because the query has to be parsed only once. German)? You can change charset variable in above line in the script to support bilanguage. We will return to it when we look at overloading.

For the most up-to-date information. this is at least 100 times faster than reading sequentially. If the table has an index for the columns in question. MySQL 3. one that is invoked when a particular event occurs. MySQL is bound by that constraint. which allows extremely large tables. you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted.22 had a 4GB (4 gigabyte) limit on table size. the maximum table size was increased to 65536 terabytes (2567 – 1 bytes). If the time required to open a file in the directory increases significantly as the number of files increases. If a table has 1. The larger the table. With this larger allowed table size.000 rows. Without an index. database performance can be adversely affected. MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. The efficiency of the operating system in handling large numbers of files in a directory can place a practical limit on the number of tables in a database. The following table lists some examples of operating system file-size limits. it is faster to read sequentially. A trigger is effectively a type of stored procedure. This allows a table to exceed the maximum individual file size. the more this costs. If you need to access most of the rows. The maximum tablespace size is 64TB. For example. What is maximum size of a database in mysql? If the operating system or filesystem places a limit on the number of files in a directory. Operating System File-size Limit . The InnoDB storage engine maintains InnoDB tables within a tablespace that can be created from several files. not by MySQL internal limits. because this minimizes disk seeks. Triggers will also be implemented. be sure to check the documentation specific to your operating system. The amount of available disk space limits the number of tables. Indexes are used to find rows with specific column values quickly. With the MyISAM storage engine in MySQL 3. The tablespace can include raw disk partitions. MySQL must begin with the first row and then read through the entire table to find the relevant rows. the maximum effective table size for MySQL databases is usually determined by operating system constraints on file sizes.23. This is only a rough guide and is not intended to be definitive.less on the client (application) side.

I do not often use Third Normal Form. those. i. We want to ensure that there is no duplication of data in a given row. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key. As stated earlier.4+ (using ext3 filesystem) 4TB Solaris 9/10 16TB NetWare w/NSS filesystem 8TB Win32 w/ FAT/FAT32 2GB/4GB Win32 w/ NTFS 2TB (possibly larger) MacOS X w/ HFS+ 2TB Explain normalization concept? The normalization process involves getting our data to conform to three progressive normal forms. so to achieve Second Normal Form. but dependant on another value in the table What‟s the difference between accessing a class method via -> and via ::? :: is allowed to access methods that can perform static operations. which do not require object initialization. Third Normal Form I have a confession to make.e. but the last two are mainly academic and will not be discussed). your tables must already be in First Normal Form. First Normal Form The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. Second Normal Form (or 2NF) deals with redundancy of data in vertical columns.2-Intel 32-bit 2GB (LFS: 4GB) Linux 2. and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms. and that every column stores the least amount of information possible (making the field atomic). the normal forms are progressive. Second Normal Form Where the First Normal Form deals with redundancy of data across a horizontal row.Linux 2. .

What are the advantages and disadvantages of CASCADE STYLE SHEETS? External Style Sheets Advantages Can control styles for multiple documents at once Classes can be created for use on multiple HTML element types in many documents Selector and grouping methods can be used to apply styles under complex contexts Disadvantages An extra download is required to import style information for each document The rendering of the document may be delayed until the external style sheet is loaded Becomes slightly unwieldy for small quantities of style definitions Embedded Style Sheets Advantages Classes can be created for use on multiple tag types in the document Selector and grouping methods can be used to apply styles under complex contexts No additional downloads necessary to receive style information Disadvantage This method can not control styles for multiple documents at once Inline Styles Advantages Useful for small quantities of style definitions Can override other style specification methods at the local level so only exceptions need to be listed in conjunction with other style methods Disadvantages Does not distance style information from content (a main goal of SGML/HTML) Can not control styles for multiple documents at once Author can not create or control classes of elements to control multiple element types within the document Selector grouping methods can not be used to create complex element addressing scenarios What type of inheritance that php supports? .

When the HTML code is parsed. Internet Explorer looks for the existence of the page in cache at that exact moment. When the metatag is read. Usually. How can we change the name of a column of a table? MySQL query to rename table: RENAME TABLE tbl_name TO new_tbl_name or. which appears at the beginning of the document. also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables. multiple inheritance is not supported. it is removed. Classes are extended using the keyword ‗extends‘. Using HTML tag <span style=‖color: red‖> When viewing an HTML page in a Browser. ALTER TABLE tableName CHANGE OldName newName. How can increase the performance of MySQL select query? We can use LIMIT to stop MySql for further search in table after we have received our required no. If it is there. it is read from top to bottom. that is. of records. the Browser often keeps this page in its cache. When you want to show some part of a text displayed on an HTML page in red font color? What different possibilities are there to do this? What are the advantages/disadvantages of these methods? There are 2 ways to show some part of a text in red: 1. A page that Internet Explorer is browsing is not cached until half of the 64 KB buffer is filled. the Web page may still be cached in the Temporary Internet Files folder.In PHP an extended class is always dependent on a single base class. What can be possible advantages/disadvantages of page caching? How can you prevent caching of a certain page (please give several alternate solutions)? When you use the metatag in the header section at the beginning of an HTML Web page. To properly prevent the Web . Using HTML tag <font color=‖red‖> 2. metatags are inserted in the header section of an HTML document.

//free the object $word->Release(). //do some weird stuff $word->Selection->TypeText(―This is a test…‖). Possible values are CP_ACP. //open an empty document $word->Documents->Add(). which can be used to identify the URL from within a HTML link tag. $word = null. place another header section at the end of the HTML document. . Usage: $word->Visible = 1.ini. Please give a regular expression (preferably Perl/PREG style).page from appearing in the cache. If NULL. string server_name [. int codepage]]) – COM class constructor. Parameters: module_name: name or class-id of the requested component. For example: What are the different ways to login to a remote server? Explain the means. allow_dcom has to be set to TRUE in php. string COM::COM( string module_name [. //closing word $word->Quit().doc‖). advantages and disadvantages? There is at least 3 ways to logon to a remote server: Use ssh or telnet if you concern with security You can also use rlogin to logon to a remote server. CP_OEMCP. server_name: name of the DCOM server from which the component should be fetched. To allow DCOM com. Try this: /href=‖([^"]*)‖/i How can I use the COM components in php? The COM class provides a framework to integrate (D)COM components into your PHP scripts. CP_SYMBOL. CP_THREAD_ACP. $word->Documents[1]->SaveAs(―Useless test. CP_UTF7 and CP_UTF8. localhost is assumed. codepage – specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. CP_MACCP.

Temporary directory for HTTP uploaded files (will use system default if not . which means order of time. your crontab will not function properly. # crontab This command ‗edits‘ the crontab. specified). upload_tmp_dir = C:\apache2triad\temp . Maximum allowed size for uploaded files. The syntax of the file should be as follows: minutes hours day_of_month month day_of_week command . Whether to allow HTTP file uploads. upload_max_filesize = 2M How can I set a cron and how can I execute it in Unix. file_uploads = On . and windows? Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. Upon employing this command.How many ways we can give the output to a browser? HTML output PHP. You can find information on using vi here. it‘s called Scheduled Tasks. Linux. My version of Linux uses the text editor vi. Servlet Function Script Language output Function Different Type of embedded Package to output to a browser What is the default session time in php and how can I change it? The default session time in php is until closing of browser What changes I have to do in php. JSP. The easiest way to use crontab is via the crontab command. ASP. The syntax of this file is very important – if you get it wrong. In Windows.ini file for file uploading? Make the following line uncomment like: . The name Cron is in fact derived from the same word from which we get the word chronology. you will be able to enter the commands that you wish to run.

g. are numerical constants. as we will see momentarily. The reason is that.All the variables. type the following: # wget help If you are greeted with a wget package identification. can also be used to execute a Web document such as a PHP file.example. In addition to an asterisk (*). it needs to be passed through Apache. command can be any shell command and.com/file. You could execute the PHP by invoking wget on the URL to the page. nothing will happen (barring very special configurations that have PHP compiled as an executable. the ranges permitted for each field are as follows: Minutes: 0-59 Hours: 0-23 Day_of_month: 1-31 Month: 1-12 Weekday: 0-6 We can also include multiple values for each entry. with the exception of the command itself. So. right? Not so fast! If you try to run a PHP script in this manner. which is a wildcard that allows any value. the page needs to be called via a browser or other means of retrieving Web content. like so: # wget http://www. Redhat or Mandrake). If you‘re using an RPM-based system (e.php . in order for PHP to be parsed. it is installed in your system. simply by separating each value with a comma. In other words. our mycronjob file will contain the following content on a single line: 15 8 * * 2 /path/to/scriptname This all seems simple enough. as is the case with most default configurations. For our purposes. To test your configuration. I‘ll assume that your server configuration includes wget. log in to shell. if we want to run a script every Tuesday morning at 8:15 AM. as opposed to an Apache module).

php Steps for the payment gateway processing? An online payment gateway is the interface between your merchant account and your Web site.5 wget http://www.= ―Content-Type: multipart/mixed.href=‖‗.$filename. echo ‖. $headers = ―From: \‖Me\‖\n‖. bool replace [. echo ‖. we can go ahead and set up our crontab to use 4:00.php file we created in the first part of this article.). It then passes the transaction off to your merchant bank for processing. Using php function: header(―Location:http://maosjb. and send you your precious closing bell report? Since I‘m located in the Eastern timezone. echo ‗window. echo ‖. 1. md5( uniqid ( rand() ) ).3. so it should be accessible via the Internet.4. Remember that we wanted it to run at 4PM Eastern time. ?> 2. List out different arguments in PHP header function? void header ( string string [.Now. you might have to compensate for the time difference when setting this value. boundary=\‖$boundary\‖".‘‖. The online payment gateway allows you to immediately verify credit card transactions and authorize funds on a customer‘s credit card directly from your Web site. echo ‖. $headers .location. Using Java script: ‗. } } redirect(‗http://maosjb. We saved it in our document root. $headers .‘.com/mailstock. let‘s go back to the mailstock.0\n‖.= ―MIME-Version: 1.2. This is what my crontab will look like: 0 4 * * 1.example. .com ―).com&#8217. but if you live elsewhere. commonly referred to as transaction batching How many ways I can redirect a PHP page? Here are the possible ways of php page redirection. int http_response_code]]) What type of headers have to be added in the mail function to attach a file? $boundary = ‗–‘ .

That is to say. then no action will occur. a variable‘s type is determined by the context in which that variable is used.How to store the uploaded file to the final location? move_uploaded_file ( string filename. and the result will also be an integer. $var becomes a string. but cannot be moved for some reason. If the file is valid. Explain about Type Juggling in php? PHP does not require (or support) explicit type definition in variable declaration. . Note that this does NOT change the types of the operands themselves. An example of PHP‘s automatic type conversion is the addition operator ‗+‘. no action will occur. If filename is not a valid upload file. string destination) This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP‘s HTTP POST upload mechanism). the operands will be interpreted as integers. then all operands are evaluated as floats. and the result will be a float. If you then assign an integer value to $var. Otherwise. and move_uploaded_file() will return FALSE. Return-path: Return path is when there is a mail delivery failure occurs then where to delivery the failure notification. If any of the operands is a float. and move_uploaded_file() will return FALSE. if you assign a string value to variable $var. Additionally. the only change is in how the operands are evaluated. a warning will be issued. What is the difference between Reply-to and Return-path in the headers of a mail function? Reply-to: Reply-to is where to delivery the reply of the mail. it becomes an integer. If filename is a valid upload file. it will be moved to the filename given by destination.

$system>getProperty(‗os. The former is provided by a SAPI module that interfaces with the Servlet server.version‘) . $system>getProperty(‗java. ‖. you can use the var_dump() function. If you would like to test any of the examples in this section. ‗ ‗ . Example Code: getProperty(‗java. so $a becomes ―f‖. and everything runs in-process. The JVM is created using JNI. PHP 4 introduced the new curly bracket syntax to access characters in string.ini file? There are two possible ways to bridge PHP and Java: you can either integrate PHP into a Java Servlet environment.$foo $foo $foo $foo += 2. ‖. the example above leads to a problem: should $a become an array with its first element being ―f‖. or integrate Java support into PHP. If you wish to change the type of a variable. // $foo is now an integer (2) = $foo + 1.version‘) . // $foo is integer (15) If the last two examples above seem odd. echo ‗Java vendor=‘ . // $foo is now a float (3.vendor‘) . // $foo is integer (15) = 5 + ―10 Small Pigs‖. or should ―f‖ become the first character of the string $a? The current versions of PHP interpret the second assignment as a string offset identification.3) = 5 + ―10 Little Piggies‖. The Java extension provides a simple and effective means for creating and invoking methods on Java objects from PHP. which is the more stable and efficient solution. echo ‗OS=‘ . . see settype(). $system->getProperty(‗os.name‘) . Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing. use this syntax instead of the one presented above: How can I embed a java programme in php file and what changes have to be done in php. Note: The behavior of an automatic conversion to array is currently undefined. the latter by this Java extension. the result of this automatic conversion however should be considered undefined. ‗ on ‗ . see String conversion to numbers.3.

$system->getProperty(‗os. otherwise.library.text. Java configuration options Name Default Changeable java. if it‘s true. the expression following : is executed. ‗ ‗.class.Date example $formatter = new Java(‗java.arch‘) .ini. then the expression preceding the : is executed. ―EEEE.path NULL PHP_INI_ALL Name Default Changeable java.SimpleDateFormat‘.util.auto_start = 1 in php.home NULL PHP_INI_ALL java. ?> The behaviour of these functions is affected by settings in php.library JAVALIB PHP_INI_ALL How To Turn On the Session Support? The session support can be turned on automatically at the site level. Turning on session support manually in each page script: Call session_start() funtion. // java. yyyy ‗at‘ h:mm:ss a zzzz‖). echo $formatter->format(new Java(‗java. MMMM dd.ini.  Explain the ternary conditional operator in PHP? Expression preceding the ? is evaluated.util.path NULL PHP_INI_ALL java. Table 1. or manually in each PHP page script:  Turning on session support automatically at the site level: Set session.Date‘)). .

What is CAPTCHA? . reads all characters in the file. a warning will be issued. that will helpfull to PHP Interview Candidates 1. How To Read the Entire File into a Single String? If you have a file. print(―Size of the file: ―. it will cause a fatal error and halt the execution of the script. and returns them in a single string. and you want to read the entire file into a single string.‖\n‖). Here is a PHP script example on how to file_get_contents(): <?php $file = file_get_contents(―/windows/system32/drivers/etc/services‖). you can use the file_get_contents() function. It opens the specified file.What‟s the difference between include and require? It‘s how they handle failures. but execution will continue. ?> This script will print: Size of the file: 7116 important PHP interview questions and answers Here is some PHP Interview Questions. If the file is not found by require().strlen($file). How can we destroy the cookie? Set the cookie in past. How many ways can we get the value of current session id? session_id() returns the session id for the current session. If the file is not found by include().

org/wiki/Captcha 2. we need to get rid of the ―@‖ sign. while include() only produces a WARNING. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. . There is also include_once() which is the same as include(). So it is best to store the dates as timestamp in the database. Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found.wikipedia. 2006 @ 10:39 am”. To read more look here: http://en. that is easier to use? The strtotime function can convert a string to a timestamp. February 14. Becouse above three function usely use to call a file in another file? Difference between require() and require_once(): require() includes and evaluates a specific file. and just output them in the format you like. but the difference between them is the same as the difference between require() and require_once(). If you have to work with dates in the following format: “Tuesday. include(). What is difference between require_once(). To prevent spammers from using bots to automatically fill out forms. CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. while require_once() does that only if it has not been included before (on the same page). February 14. So. In order to convert that to a timestamp. require(). and we can use the remaining string as a parameter for the strtotime function. This way you make sure you don‘t include the file more times and you will not get the ―function re-declared‖ error. By entering the numbers and letters from the image in the validation field. 3. the application can be fairly assured that there is a human client using it. how can you convert them to another format.CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. require_once() is recommended to use when you want to include a file where you have a lot of functions for example. 2006 @ 10:39 am‖. A timestamp can be converted to date format. So let‘s say we have $date = ―Tuesday.

$date). How i can get ip address? We can use SERVER var $_SERVER['SERVER_ADDR'] and getenv(―REMOTE_ADDR‖) functions to get the IP address. echo $_SERVER['HTTP_USER_AGENT'] . $browser = get_browser(). ― \n‖. 4. where i was working)? For this we can use the session objec($_SESSION)t. How i will check that user is.$date). } 5. usually we check those to ensure for correctness. foreach ($browser as $name => $value) { echo ―$name $value \n‖. now $date is a timestamp and we can say: echo date(―d M Y‖.ini file. i want to make it a function and i want to use in each page and after login i want to go in current page(same page. $date = strtotime($date). logged in or not. How we know browser properties? get_browser() attempts to determine the capabilities of the user‘s browser. . 6.‖". This is done by looking up the browser‘s information in the browscap.So we have $date = str_replace(―@ ―. If that user name and password are valid one then we can store that user name in a session and then we can very that session variable has been set or not in a single files and we can include that file in all pages. When the user login with his/ her user name and password.

It will hold open a connection to the db that you can use over and over again simply by calling the resource ID whenever you need to interact with the db. All this can get into a rather complicated discussion. from session of user we can get the user detail 10) What is the difference between inner join and outer join? Inner join displays rows from table where the data is available in both the tables. That‘s the beauty of it. How to make a download page in own site. Echo does not return a value. but has been considered as a faster executed command. The only time you need to close the connection manually is if you jump out of the script for any reason. Using the print method can return a true/false value. You only need to call it once for the session. What is difference between mysql_connect and mysql_pconnect? mysql_pconnect establishes a persistent connection. and we only allow regisetered user to download. Inner join Say you have one table of CUSTOMERS and one table of ORDERS. 8. If you do use mysql_pconnect. Once the script has finished executing it closes the connection. If you want to run a query that lists the orders along with the names of the customers who ordered them (since a customer id number itself it pretty useless). 9. If you don‘t need one (such as a website that is mostly HTML files or PHP files that don‘t call the db) then you don‘t need to use it. you will want to execute a join query: . where in outer join we can configure it to bring out rows from one table where the data is missing in other table for the corresponding rows.7. you can just use whichever one you prefer. Each row in the ORDERS table has a reference (foreign key reference) to a customer id which represents what customer placed that order. mysql_connect establishes a connection for the duration of the script that access the db. What is the difference between echo and print statement? There is a slight difference between print and echo which would depend on how you want to use the outcome. so for now. which i can know that how many file has been loaded by particular user or particular ip address? We can use hyperlink having URL where file are kept. This may be helpful during a script execution of somesort.

you wanted the query results to return all customer name regardless of whether they placed an order.NAME.NAME FROM CUSTOMERS INNER JOIN ORDERS ON CUSTOMERS.CUSTOMER_ID Outer join If for some reason.SELECT CUSTOMERS. ORDERS.NAME FROM CUSTOMERS LEFT JOIN ORDERS ON CUSTOMERS. a LEFT JOIN: SELECT CUSTOMERS.ID = ORDERS. ORDERS.ID = ORDERS.CUSTOMER_ID . in this case. you can use one of two types of OUTER JOINS.NAME.