These are the some php interview questions from www.w3answers.com have answered for some questions
- 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?
get is like query string all the variables will be displayed in he url
where as post is the standard way of sending th evariables
When we submit a form, 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. Post method doesn’t display these values.
Who is the father of PHP and explain the changes in PHP versions?
Father of php is Rasmus Lerdorf
How can we submit a form without a submit button?
Ans : I can submit a form in many ways, for e.g.
When user click on checkbox, or drop down
When user click on radio button
At the end of the form I will type “Click here
to submit” & link text to the processing file
In how many ways we can retrieve the date in the result set of mysql using PHP?
What is the difference between mysql_fetch_object and mysql_fetch_array?
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).
mysql_fetch_object is like fetching value from a recordset
and mysql_fetch_array is gettin array’s value
- What is the difference between $message and $$message?
$message is variable whereas $$message is Dynamic variable.
is equivalent to
How can we extract string ‘abc.com ‘ from a string ‘http://firstname.lastname@example.org’ using regular expression of PHP?
$exploded should have abc.com
Use the function split split(“@”,”http://email@example.com”) which returns an array any second element of the returned array will hold the value as abc.com.
How can we create a database using PHP and mysql?
mysql_create_db() should work
What are the differences between require and include, include_once?
require_once(),include_once() both the functions include and evalute the specified file only once
and if the specified file is opened previous to the present call occurrance, it will not be done again.
But require() and include() will do it as many times they are asked to do.
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include produces a warning message whereas require produces a Fatal errors.
Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
Yes we can include that many times we want, but here are some things to make sure of:
(including abc.PHP, the file names are case-sensitive)
there shouldnt be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php
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),ename varchar(10)) ?
Table Types are
• ISAM(Index Sequential Access Method)
• Heap (Fastest tables because it stores in to the RAM)
• InnoDB (Transaction safe table)
When you fire the above create query MySQL will create the Dynamic table.
Functions in IMAP, POP3 AND LDAP?
How can I execute a PHP script using command line?
Through php parse you can execute PHP script using command line. By default location of php parser is /var/www/html so set the path of this directory and just use as following
Suppose your Zend engine supports the mode <? ?> Then how can u configure your PHP Zend engine to support <?PHP ?> mode ?
In php.ini file:
to make PHP support
Shopping cart online validation i.e. how can we configure Paypal, etc.?
What is meant by nl2br()?
nl2br() inserts html in string. echo nl2br(”god bless
Draw the architecture of Zend engine?
What are the current versions of apache, PHP, and mysql?
What are the reasons for selecting lamp (linux, apache, mysql, PHP) instead of combination of other software programmes, servers and operating systems?
How can we encrypt and decrypt a data present in a mysql table using mysql?
How can we encrypt the username and password using PHP?
You can encrypt a password with the following
What are the features and advantages of object-oriented programming?
What are the differences between procedure-oriented languages and object-oriented languages?
What is the use of friend function?
What are the differences between public, private, protected, static, transient, final and volatile?
What are the different types of errors in PHP?
Three are three types of errors 1) Fatal errors 2) Parser errors 3) Startup errors.
What is the functionality of the function strstr and stristr?
string strstr ( string str1, string str2) this function search the string str1 for the first occurrence of the string str2 and returns the part of the string str1 from the first occurrence of the string str2. This function is case-sensitive and for case-insensitive search use stristr() function.
What are the differences between PHP 3 and PHP 4 and PHP 5?
How can we convert asp pages to PHP pages?
What is the functionality of the function htmlentities?
How can we get second of the current time using date function?
How can we convert the time zones using PHP?
What is meant by urlencode and urldocode?
where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world
this will simple decode the GET variable’s value
Like it echo (urldecode($_GET_VARS[var])) will o/p “Hello world”
What is the difference between the functions unlink and unset?
How can we register the variables into a session?
How can we get the properties (size, type, width, height) of an image using PHP image functions?
How can we get the browser properties using PHP?
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
How can we increase the execution time of a PHP script?
How can we take a backup of a mysql table and how can we restore it. ?
How can we optimize or increase the speed of a mysql select query?
How many ways can we get the value of current session id?
How can we destroy the session, how can we unset the variable of a session?
How can we destroy the cookie?
How many ways we can pass the variable through the navigation between the pages?
What is the difference between ereg_replace() and eregi_replace()?
eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.
What are the different functions in sorting an array?
How can we know the count/number of elements of an array?
What is the PHP predefined variable that tells the What types of images that PHP supports?
List out some tools through which we can draw E-R diagrams for mysql.
How can I retrieve values from one database server and store them in other database server using PHP?
List out the predefined classes in PHP?
Standard Defined Classes
These classes are defined in the standard set of functions included in the PHP build.
The class from which dir() is instantiated.
2.Ming Defined Classes
These classes are defined in the Ming extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
a.swfshape b. swffill c. swfgradient d. swfbitmap e. swftext f. swftextfield
g. swffont h. swfdisplayitem i. swfmovie j. swfbutton k. swfaction
l. swfmorph m. swfsprite
Oracle 8 Defined Classes
These classes are defined in the Oracle 8 extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
a. OCI-Lob b. OCI-Collection
qtdom Defined Classes
These classes are defined in the qtdom extension, and will only be available when that extension has either been compiled into PHP or dynamically loaded at runtime.
a. QDomDocument b. QDomNode
How can I make a script that can be bilanguage (supports English, German)?
What are the difference between abstract class and interface?
The answer for this question
This question is wrong. You aren’t really ’sending mail’ when doing a ‘mailto’ and so it’s a misleading question… A smart candidate would just say “It’s not possible” and you may write him off.