PHP Interview Questions - Set 3

PHP Interview Questions

Share

This page contains PHP interview questions and answers.

Q1: Briefly explain the __construct and __destruct method in PHP

Every class in PHP gets a Constructor __construct method and Destructor __destruct method by default if it is not explicitly defined.

The Constructor method is executed immediately after the creation of an instance of the class.

We use constructor method to initialise the properties of the class object.

The Destructor method is called when all references to the class object are removed or explicitly destroyed.

We use the destructor method to release any resources that we have acquired during code execution. Example, closing of database connection or closing of file resource.

Q2: How will you check if the submitted email and password via POST request is not empty?

For this we can use the empty function.

The following code will print error message if both the email and password submitted is empty.

if (empty($_POST['email']) && empty($_POST['password'])) {
  echo 'Email and Password both are empty.';
}

Q3: What is PEAR?

PEAR or PHP Extension and Application Repository is a framework and distributed system of reusable PHP components.

It is a structured library of open source PHP code for developers.

Q4: What is PSR?

PSR stands for PHP Standards Recommendations and it is a set of recommendations for writing PHP code.

Q5: What was PHP initially called?

PHP was initially called Personal Home Page.

Q6: What is the new name for PHP?

PHP now stands for PHP: Hypertext Preprocessor.

Q7: What is the engine called for PHP?

The scripting engine powering PHP is called Zend Engine.

Q8: Who created PHP?

Rasmus Lerdorf created PHP.

Q9: Name some of the popular CMS written in PHP?

Following are some of the popular Content Management System CMS written in PHP.

  • Wordpress
  • Drupal
  • Joomla

Q10: Name some of the popular PHP frameworks

Following are some of the popular PHP framework.

  • Laravel
  • Symfony
  • CakePHP
  • CodeIgniter
Share

Recently Updated