Top PHP Interview Questions and Answers in 2020

PHP Interview Questions

PHP is the “Hypertext Pre-Processor” is the open-source easy to learn and widely used programming language by the website developer. It is a flexible scripting language that allows developers to build an extensive website easily with creative web pages.

PHP has broad coverage to the website and mobile API that’s the reason many software development companies keep hiring skilled developers in PHP. So, if you are looking for an opportunity to kick start your Career as a PHP Developer here we are presenting 30 Most Frequently Asked PHP Developer Interviews questions.

Table of Contents [ Top PHP Interview Questions ]

1 What is PHP?

Ans :

PHP is an open-source server-side scripting language internally embedded with HTML. PHP stands for “Hypertext Pre-processor”. It is easy to understand flexible and developer-friendly programming language which allows you to manage dynamic content, Databases, Sessions, Cookies, and develop any small to a large scale website.

Even E-commerce and CRM products can be also built using this language. PHP is the first choice for an aspiring developer who is looking to grab a skill to build a website or start their first project.

2 Who had invented PHP and known as the father of it?

Ans :

Rasmus Lerdorf had invented PHP and he is also known as the father of PHP.

3 What was the name of PHP in the early days?

Ans :

PHP was initially known as Personal Home Page, which is later got transformed into Hypertext Pre-Processor.

4 What do you understand by static and dynamic website? Explain the Difference.

Ans :

  • Static Website: Static website holds pre-defined content that cannot be changed once the script is running on the web.
  • Dynamic Website: The website content can be changed at any point in time even though the website is running on the web. Whenever a user loads the website it reflects its content. For example, your Google search engine is the best example of a Dynamic website.

5 Name the scripting Engine of PHP.

Ans :

Zend Engine is the power of PHP which allows the scripting.

6 Name the popular Content Management System supported by PHP.

Ans :

WordPress

wordpressIt is an open-source easily available CMS system which supports PHP and Mysql. Word press is built on plug-in architecture and it supports the template system. It is widely used for blogging purpose but it also supports traditional mailing lists and forms along with online stores and media displays.

Joomla

Joomla Joomla is also an open-source and easily available CMS system that allows users to do N number of experiments. Joomla was created by Open Source Matters inc and it is based on distributed content architecture. It also consists of MVC (Model View Controller )Architecture for the web-based framework. Joomla can be used independently for CMS.

Magento

magentoMagento is also an open-source easily available E-Trade programming invented by Varien Inc. It gives you broad flexibility in terms of variant designs with diverse control alternatives that are helpful for the developers. It is based on the E-trade stage that allows companies E-business agreements and a wide support network.

Drupal

drupal

Drupal is a distributed CMS system developed in PHP and it works on General Public Licensing.

 


7 Is PHP a case sensitive Programming language?

Ans :

It is not fully but partially a case sensitive programming language. Function names are case insensitive but the variables are case sensitive. You get a flexibly to define your function in lower case and call that same function in upper case. All the user-defined functions are case insensitive but the rest of the language is sensitive.

8 What is known as PEAR in PHP?

Ans :

PEAR (PHP Extension and Application Repository) is a PHP framework and repository which allows the re-usability of PHP code. It is extensive storage of all kinds of PHP code snippets and libraries. PEAR also provides command-line interfaces for allowing the installation of “Packages” automatically.

9 List out a few common usages of PHP

Ans :

  • You can perform system functions easily such as It can create, Open, Read, Write, and close.
  • You can handle forms such as gather data from a file, save data into the file, share data through email, and return data to the user as output.
  • Database elements can be added, deleted, modified using PHP easily
  • You can access cooking handle sessions flexibly.
  • Best used for restricting users from using some pages on your website.

10 What are the different type of variables supported in PHP

Ans :

  1. Integer: Any whole number without decimal.

  2. Boolean: Either True or False

  3. Double: Any Floating point number

  4. Null: Only null

  5. String: Sequence of character or simple sentence like ”Hello World ”

  6. Arrays: Indexed and named collection of values (string, number)

  7. Objects: Instance of user-defined class. It can package both values and functions as per the need.

  8. Resources: Holds the references to variables that are external to PHP.

11 Define the rules for naming a PHP Variable.

Ans :

For Naming the PHP variable you should follow the below rules.

  1. A variable name should start with a letter or underscore character.
  2. A variable name can consist of these: numbers, letters, underscore but you cannot use the character (+, -,%, (,),&, etc).

12 What is NULL in PHP or any other programming language?

Ans :

NULL is a special kind of data type that only has a single value. If a variable is NULL it means that the variable has no value assigned to it. NULL can be assigned as below.

$ var =NULL;

Capitalize NULL is conventional in special constant otherwise use can represent it as below.

$var=null;

The NULL variable has two important properties

  1. It represents and evaluates the value false is the data type is Boolean.
  1. It also return false when tested with IsSet() PHP function.

13 What is constant is PHP and how do you define that?

Ans :

Constant is the value in PHP which can never be changed. With the use of define () function, you can define a constant in PHP. To retrieve the constant value you simply need to simplify the constant. Constant values as the name itself represent can never be changed once it is defined. You do not need to define constant with $ sign. A valid constant starts with a letter and underscore.