PHP Interview Questions and Answers – Part 1

1 What is Full form of PHP ? Who is the father or inventor of PHP ?
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.

2 What are the differences between PHP3 and PHP4 and PHP5 ? what is the current stable version of PHP ? what advance thing in php6
The current stable version of PHP is PHP 5.4.5 as still waiting for PHP6 with 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
1>PHP3 is oldest stable version and it was pure procedural language constructive like C
2>Where as PHP4 have some OOPs concept added like class and object with new functionality
3>and in PHP5 approximately all major oops functionality has been added along with below thing
1. Implementation of exceptions and exception handling
2. Type hinting which allows you to force the type of a specific argument
3. Overloading of methods through the __call function
4. Full constructors and destructors etc through a __constuctor and __destructor function
5. __autoload function for dynamically including certain include files depending on the class you are trying to create.
6 Finality : can now use the final keyword to indicate that a method cannot be overridden by a child. You can also declare an entire class as final which prevents it from having any children at all.
7 Interfaces & Abstract Classes
8 Passed by Reference :
9 An __clone method if you really want to duplicate an object
10 Numbers of Functions Deprecated or removed in PHP 5.x like ereg,ereg_replace,magic_quotes, session_register,register_globals, split(), call_user_method() etc

3 Is variable name casesensitive ? could we start a variale with number like $4name ? What is the difference between $name and $$name?
Yes variable name casesensitive and we can’t 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.

4 How do you connet mysql database with PHP ?
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”);
and in old type of connectivity were
$link = mysql_connect(“localhost”, “username”, “password”);

5 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 ?
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).

6 What are the differences between Get and post methods.
There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request

7 How can we extract string “ ” from a string “ using regular expression of PHP?
echo $matches[1];

8 How can we create a database using PHP and MySQL?
We can create MySQL database with the use of
mysql_create_db(“Database Name”)

9 What are the differences between require and include?
Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error .

10 Can we use include (“xyz.PHP”) two times in a PHP page “index.PHP”?
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

11 What are the different tables(Engine) present in MySQL, which one is default?
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.)
3. Merge
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)

12 What is use of header() function in php ?
The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen..

13 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.

14 Suppose your Zend engine supports the mode <? ?> Then how can you configure your PHP Zend engine to support <?PHP ?> mode ?
In php.ini file:
to make PHP support

15 Shopping cart online validation i.e. how can we configure Paypal, etc.?
Nothing more we have to do only redirect to the payPal url after submit all information needed by paypal like amount,adresss etc.

16 What is meant by nl2br()?
Inserts HTML line breaks (<BR />) before all newlines in a string.

17 What is htaccess? Why do we use this and Where?
.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
subdirectories thereof.

18 How we get IP address of client, previous reference page etc ?

19 What are the reasons for selecting lamp (Linux, apache, MySQL, PHP) instead of combination of other software programs, servers and operating systems?
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.

20 How can we encrypt and decrypt a data present in a MySQL table using MySQL?

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Get Alert

    Enter your email address:

  • Categories

  • Twitter

Subscribe Now!
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.

Subscribe Here

Popup Dialog Box Powered By :
  • RSS
  • Facebook
  • Google+
  • Twitter