PHP Interview Questions and Answers for freshers and experienced – 01
|Questions : 1||What is Full form of PHP ? Who is the father or inventor of PHP ?|
|Answers : 1||Rasmus Lerdorf is known as the father of PHP that started development of PHP in 1994
for their own Personal Home Page (PHP) and they released PHP/FI (Forms Interpreter) version 1.0 publicly on 8 June 1995 But in 1997 two Israeli developers named Zeev Suraski and Andi Gutmans rewrote the parser that formed the base of PHP 3 and then changed the language’s name to the PHP: Hypertext Preprocessor.
|Questions : 2||What are the differences between PHP3 and PHP4 and PHP5 ? what is the current stable version of PHP ? what advance thing in php6
|Answers : 2||The current stable version of PHP is PHP 5.4.11 on 2013-01-17 as still waiting for PHP6with unicode handlig thing
There are lot of difference among PHP3 and PHP4 and PHP5 version of php so Difference mean oldest version have less functionality as compare to new one like
|Questions : 3||Is variable name casesensitive ? could we start a variale with number like $4name ? What is the difference between $name and $$name?|
|Answer : 3||Yes variable name casesensitive and we can not start a variable with number like $4name as A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.
where as $$ is variable of variable $name is variable where as $$name is variable of variable
like $name=sonia and $$name=singh so $sonia value is singh.
|Questions : 4||What is use of header() function in php ? What the Limitation of HEADER()?|
|Answers : 4||In PHP Important to notice the Limitation of HEADER() function is that header() must be called before any actual output is send. Means must use header function before HTML or any echo stateament
There are Number of Use of HEADER() function in php like below
1> The header() function use to sends a raw HTTP header to a client.
2> We can use herder() function for redirection of pages.
3> Use for refresh the page on given time interval automatically.
4> To send email header content like cc, bcc , reply to etc data and lot more .
|Questions : 5||How can we extract string “pcds.co.in” from a string “http://[email protected]” using regular expression of PHP? More on Reg can you explain|
|Answers : 5||We can extract string “pcds.co.in” using this
preg_match(“/^http:\/\/[email protected](.+)$/”,”http://[email protected]”,$matches);
More On regular expression interview question with very nice examples in
|Questions : 6||How do you connet mysql database with PHP ?|
|Answer : 6||We can connect Mysql Database with PHP using both Procedural and Object oriented style like below
$link = mysqli_connect(“localhost”, “username”, “password”, “dbofpcds”);
$mysqli = new mysqli(“localhost”, “username”, “password”, “dbname”);
|Questions : 7||In how many ways we can retrieve the data in the result set of
MySQL using PHP? What is the difference between mysql_fetch_object and mysql_fetch_array ?
|Answers : 7||we can retrieve the data in the result set of MySQL using PHP in 4 Ways
1. mysqli_fetch_row >> Get a result row as an enumerated array
2. mysqli_fetch_array >> Fetch a result row as associative and numeric array
3.mysqli_fetch_object >> Returns the current row of a result set as an object
4. mysqli_fetch_assoc >> Fetch a result row as an associative array
mysqli_fetch_object() is similar to mysqli_fetch_array(), with one difference –
an object is returned, instead of an array. Indirectly, that means that
we can only access the data by the field names, and not by their
offsets (numbers are illegal property names).
|Questions : 8||How can we create a database using PHP and MySQL?|
|Answers : 8||We can create MySQL database with the use of
|Questions : 9||What are the differences between require and include?|
|Answers : 9||Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error .
|Questions : 10|| Can we use include (“xyz.PHP”) two times in a PHP page “index.PHP”?
|Answers : 10||Yes we can use include(“xyz.php”) more than one time in any page. but it create a prob when xyz.php file contain some funtions declaration then error will come for already declared function in this file else not a prob like if you want to show same content two time in page then must incude it two time not a prob|
|Questions : 11||What are the different tables(Engine) present in MySQL, which one is default?|
|Answers : 11|| Following tables (Storage Engine) we can create
1. MyISAM(The default storage engine IN MYSQL Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type. An .frm file stores the table format. The data file has an .MYD (MYData) extension. The index file has an .MYI (MYIndex) extension. )
2. InnoDB(InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.)
4. Heap (MEMORY)(The MEMORY storage engine creates tables with contents that are stored in memory. Formerly, these were known as HEAP tables. MEMORY is the preferred term, although HEAP remains supported for backward compatibility. )
5. BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the Berkeley DB transactional storage engine. This storage engine typically is called BDB for short. BDB tables may have a greater chance of surviving crashes and are also capable of COMMIT and ROLLBACK operations on transactions)
7. FEDERATED (It is a storage engine that accesses data in tables of remote databases rather than in local tables. )
8. ARCHIVE (The ARCHIVE storage engine is used for storing large amounts of data without indexes in a very small footprint. )
9. CSV (The CSV storage engine stores data in text files using comma-separated values format.)
10. BLACKHOLE (The BLACKHOLE storage engine acts as a “black hole” that accepts data but throws it away and does not store it. Retrievals always return an empty result)
|Questions : 12||What are the differences between Get and post methods.|
|Answers : 12||
There are some defference between GET and POST method
|Questions : 13||How can I execute a PHP script using command line?|
|Answers : 13||Just run the PHP CLI (Command Line Interface) program and
provide the PHP script file name as the command line argument.
|Questions : 14||Suppose your Zend engine supports the mode <? ?> Then how can u
configure your PHP Zend engine to support <?PHP ?> mode ?
|Answers : 14||In php.ini file:
to make PHP support
|Questions : 15||Shopping cart online validation i.e. how can we configure Paypal,
|Answers : 15||Nothing more we have to do only redirect to the payPal url after
submit all information needed by paypal like amount,adresss etc.
|Questions : 16||What is meant by nl2br()?|
|Answers : 16||Inserts HTML line breaks (<BR />) before all newlines in a string.|
|Questions : 17||What is htaccess? Why do we use this and Where?|
|Answers : 17||.htaccess files are configuration files of Apache Server which provide
a way to make configuration changes on a per-directory basis. A file,
containing one or more configuration directives, is placed in a particular
document directory, and the directives apply to that directory, and all
|Questions : 18||How we get IP address of client, previous reference page etc ?|
|Answers : 18||By using $_SERVER[‘REMOTE_ADDR’],$_SERVER[‘HTTP_REFERER’] etc.|
|Questions : 19||What are the reasons for selecting lamp (Linux, apache, MySQL,
PHP) instead of combination of other software programs, servers and
|Answers : 19||All of those are open source resource. Security of Linux is very
very more than windows. Apache is a better server that IIS both in
functionality and security. MySQL is world most popular open source
database. PHP is more faster that asp or any other scripting language.
|Questions : 20||How can we encrypt and decrypt a data present in a MySQL table
|Answers : 20||AES_ENCRYPT () and AES_DECRYPT ()|