Menu

PHP Interview Questions and Answers

PHP is a widely used open-source server-side scripting language especially used for creating dynamic websites, REST APIs, etc. 

PHP code is embedded within the HTML. PHP supports many databases like MySQL, Oracle, PostgreSQL, Solid, Sybase, etc. It is used to manage session tracking, and dynamic content and to build an entire e-commerce website.

In this article, let us discuss the most commonly asked PHP Interview questions for freshers and experienced.

What is PHP?

PHP is a widely used open-source scripting language that is especially used to design a website or Web application. It is a server-side scripting language and it can embed with static websites, dynamic websites, or web applications.

What is the full form of PHP?

PHP stands for Hypertext Preprocessor and earlier it was abbreviated as Personal Home Page.

What are the uses of PHP?

  • It is a server-side scripting language used to develop web applications or dynamic websites.
  • Form handling, file handling concepts, and email integration
  • It can perform a variety of system functions such as open, read, write, etc.
  • It provides an easy way to provide restricted access to the required content of the website.

Who is known as the father of PHP?

Rasmus Lerdorf

What was the old name of PHP?

Personal Home Page.

What is PEAR in PHP?

PEAR stands for PHP Extension and Application Repository. It provides a command line interface to install packages automatically. It contains all types of PHP libraries and code snippets.

Is PHP a case-sensitive scripting language?

The answer is both yes and no, which Means PHP is partially case-sensitive. Function names, constructs, and class names in PHP are not case-sensitive, while variable names and their declarations are case-sensitive.

How is a PHP script executed using a Command line interface?

           php filename.php

What is the naming rule of variables in PHP?

  • A variable starts with a $ sign followed by the variable name.
  • Variable names are case-sensitive.
  • A variable name can contain only alpha-numeric characters and underscores (_, A-Z, a-z).
  • A variable name cannot start with a number.
  • A variable name should start with an underscore or letter.

What are the different types of data types in PHP?

  • Integer - It is a nondecimal number
  • Float - A number with a decimal point
  • String - Sequence of characters, Eg, Hello World
  • Boolean - Represents two possible values - TRUE or FALSE
  • Array - Array stores multiple values under a common name.
  • Object - The object is an Instance of a class.
  • NULL - Special data type which can have only one value
  • Resource 

Explain the difference between $msg and $$msg.

  • $msg is a regular variable. Whereas, $$msg is a reference variable
  • Data stored in $msg is fixed. Whereas, the value of the $$msg can change dynamically as the value of the variable changes.
  • $msg has a fixed value and name. Whereas, $$msg can change as per the value of variable changes. 

What are the popular frameworks in PHP?

There are many popular frameworks in PHP. Following are  some of them.

  • Laravel
  • Codeigniter
  • Yii
  • Zend 
  • Symphony
  • Phalcon

What are the different types of arrays in PHP?

In PHP, there are 3 types of arrays in PHP

  • Indexed arrays
  • Associative arrays
  • Multidimensional arrays