18 PHP Interview Questions And Answers

 1) What is PHP?

PHP is a server-side scripting language that lets developers to dynamically create web applications. PHP stands for PHP: Hypertext Preprocessor.  The syntax of PHP language is quite similar to C and Perl.

2) What is PEAR?

PEAR stands for “PHP Extension and Application Repository”. It extends PHP by giving a higher level of programming to web developers.

3) What are the famous Content Management Systems (CMS) in PHP?

  • Joomla
  • Drupal
  • Magento
  • WordPress

4) What do you mean by “echo” in PHP?

Echo is used to display data on the webpage. The syntax for PHP is given below:

<? php echo ‘Hello PHP’; ?>

5) How to include a file to a PHP page?

To include a file on PHP, require () and include () functions are used along with file path as its parameter.

6) What is count () function in PHP?

In PHP, count () is used to count all the elements present in the array or in an object.

7) What the difference is between include and require?

If the file cannot be found by include (), a warning will be issued and the script will still be executed. If the file is not found by require (), then it will generate a fatal error and the execution of the script will be stopped.

8) How to define an array in PHP?

The syntax for declaring an array in PHP is given below:

var $color=array(‘red’,’blue’,’green’,’yellow’);

9) List some popular frameworks in PHP?

Some of the popular frameworks in PHP are mentioned below:

  • Zend
  • CodeIgniter
  • CakePHP
  • Yii 2
  • Symfony

10) Explain the difference between echo and print?

Echo displays one or more string as an output while print shows only one string as an output and return 1. Echo is quicker than print and also does not give any value in return.

11) How to declare a variable in PHP?

Variable is a memory location that holds the data. In PHP, the syntax variables are used for temporary storage and syntax for that is given below:



12) Explain the difference between PHP 5 and PHP4?

PHP 5 comes with OOPS (Object Oriented Programming) functionality.

13) Does PHP support multiple inheritance?

No, PHP does not support multiple inheritance. It only supports single inheritance.

14) What is single inheritance?

PHP only supports single inheritance that means a class be extended by one single class using the keyword ‘extends’.

15) Name the types of loops used in PHP?

Four types of loops are used in PHP.

  • for
  • foreach
  • While
  • do while

16) What is the difference between POST and GET methods?

GET can send 1024 bytes of data while POST can send a large amount of data. POST method is more secure than GET method.

17) Explain the use of in_array() function in PHP?

in_array() function is basically used to check if the value is present in an array or not.

18) How to set cookies in PHP?

We use setcookie function in to set a cookie PHP. For eg.

setcookie(“color”, “blue”, time()+


You may also like...

Leave a Reply

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