PHP Interviews Questions

PHP Interviews Questions

What is PHP?

 "PHP: Hypertext Preprocessor"

  • PHP is a widely-used, open-source scripting language
  • PHP scripts are executed on the server
  • PHP is free to download and use

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web-based software applications. This tutorial helps you to build your base with PHP.


What is PHP Syntax?

<?php
// PHP code goes here
?>


How To Write Comments in PHP?

<!DOCTYPE html>
<html>
<body>

<?php
// This is a single-line comment

# This is also a single-line comment
?>

</body>
</html>

 


 

How To Declaring PHP Variable?

<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>


 What was the old name of PHP?

The old name of PHP was Personal Home Page.


 Explain the difference b/w static and dynamic websites?

In static websitescontent can't be changed after running the script. You can't change anything on the site. It is predefined.

In dynamic websitescontent of script can be changed at the run time. Its content is regenerated every time a user visit or reload. Google, yahoo and every search engine is the example of dynamic website.


 What is the name of scripting engine in PHP?

The scripting engine that powers PHP is called Zend Engine 2.

 


 Explain the difference between PHP4 and PHP5.

PHP4 doesn't support oops concept and uses Zend Engine 1.

PHP5 supports oops concept and uses Zend Engine 2.


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

  • WordPress: WordPress is a free and open-source content management system (CMS) based on PHP & MySQL. It includes a plug-in architecture and template system. It is mostly connected with blogging but supports another kind of web content, containing more traditional mailing lists and forums, media displays, and online stores.
  • Joomla: Joomla is a free and open-source content management system (CMS) for distributing web content, created by Open Source Matters, Inc. It is based on a model-view-controller web application framework that can be used independently of the CMS.
  • Magento: Magento is an open source E-trade programming, made by Varien Inc., which is valuable for online business. It has a flexible measured design and is versatile with many control alternatives that are useful for clients. Magento utilizes E-trade stage which offers organization extreme E-business arrangements and extensive support network.
  • Drupal: Drupal is a CMS platform developed in PHP and distributed under the GNU (General Public License).

 What are the popular frameworks in PHP?

  • CakePHP
  • CodeIgniter
  • Yii 2
  • Symfony
  • Zend Framework etc.

 Which programming language does PHP resemble to?

PHP has borrowed its syntax from Perl and C.


 List some of the features of PHP7.

  • Scalar type declarations
  • Return type declarations
  • Null coalescing operator (??)
  • Spaceship operator
  • Constant arrays using define()
  • Anonymous classes
  • Closure::call method
  • Group use declaration
  • Generator return expressions
  • Generator delegation
  • Space ship operator

 What is "echo" in PHP?

PHP echo output one or more string. It is a language construct not a function. So the use of parentheses is not required. But if you want to pass more than one parameter to echo, the use of parentheses is required.

Syntax:

  1. void echo ( string $arg1 [, string $... ] )  

 


 What is "print" in PHP?

PHP print output a string. It is a language construct not a function. So the use of parentheses is not required with the argument list. Unlike echo, it always returns 1.

Syntax:

  1. int print ( string $arg)  

 


 What is the difference between "echo" and "print" in PHP?

Echo can output one or more string but print can only output one string and always returns 1.

Echo is faster than print because it does not return any value.


How a variable is declared in PHP?

A PHP variable is the name of the memory location that holds data. It is temporary storage.

Syntax:

  1. $variableName=value;  

 


 What is the difference between $mm and $$mm?

$mm stores variable data while $$mm is used to store variables of variables.

$mm stores fixed data whereas the data stored in $$mm may be changed dynamically.


 What are the ways to define a constant in PHP?

PHP constants are names or identifiers that can't be changed during the execution of the script. PHP constants are defined in two ways:

  • Using define() function
  • Using const() function

 


 What are magic constants in PHP?

PHP magic constants are predefined constants, which change based on their use. They start with a double underscore (__) and end with a double underscore (__).

 


How many data types are there in PHP?

PHP data types are used to hold different types of data or values. There are 8 primitive data types which are further categorized in 3 types:

  • Scalar types
  • Compound types
  • Special types

 


 How to do single and multi-line comments in PHP?

PHP single line comment is made in two ways:

  • Using // (C++ style single line comment)
  • Using # (Unix Shell-style single line comment)

PHP multi-line comment is made by enclosing all lines within.


What are the different loops in PHP?

For, while, do-while and for each.


 What is the use of the count() function in PHP?

The PHP count() function is used to count total elements in the array, or something an object.


What is the use of the header() function in PHP?

The header() function is used to send a raw HTTP header to a client. It must be called before sending the actual output. For example, you can't print any HTML element before using this function.


 What does isset() function?

The isset() function checks if the variable is defined and not null.


 Explain PHP parameterized functions.

PHP parameterized functions are functions with parameters. You can pass any number of parameters inside a function. These given parameters act as variables inside your function. They are specified inside the parentheses, after the function name. Output depends upon dynamic values passed as parameters into the function.


Explain PHP variable-length argument function

PHP supports variable-length argument function. It means you can pass 0, 1, or n number of arguments in a function. To do this, you need to use 3 ellipses (dots) before the argument name. The 3 dot concept is implemented for variable-length argument since PHP 5.6.


Explain PHP variable-length argument function.

PHP supports variable-length argument function. It means you can pass 0, 1, or n number of arguments.


 What is the array in PHP?

An array is used to store multiple values in a single value. In PHP, it orders maps of pairs of keys and values. It saves the collection of the data type.

 


 How many types of the array are there in PHP?

There are three types of the array in PHP:

  1. Indexed array: an array with a numeric key.
  2. Associative array: an array where each key has its specific value.
  3. Multidimensional array: an array containing one or more arrays within itself.

Explain some of the PHP array functions?

There are many array functions in PHP:

  • array()
  • array_change_key_case()
  • array_chunk()
  • count()
  • sort()
  • array_reverse()
  • array_search()
  • array_intersect()

 


Admin

info@closelocation.com

I had an amazing experience at PHP Interviews Questions ! The staff were friendly and attentive, creating a welcoming atmosphere. The quality of the products/services was outstanding and exceeded my expectations. If you're looking for exceptional service and a great vibe, I highly recommend visiting this place!

Related Posts

Subscribe to Newsletter!

Subscribe to get latest updates and information.

Notification