PHP Interview Questions
1 .
What is PHP ?
PHP is an acronym for PHP: Hypertext Preprocessor it is a widely-used open source(free).  PHP is a server-side scripting language designed primarily for web development and web applications. Originally created by Rasmus Lerdorf in 1994.
2 .
What is the use of "echo" in php ?
It is used to print a data in the webpage, Example: <?php echo 'Free Time Learn'; ?> , The following code print the text in the webpage.
3 .
What does a special set of tags do in PHP?
The output is displayed directly to the browser.
4 .
What is PHP Variables ?
PHP Variables are used for storing data such as numeric values, characters, character strings etc. All PHP variable names must be pre-fixed with a ( $). Variable names are case-sensitive they are ($var and $VAR are two different variables).

Syntax of declaring a PHP valid and invalid variable names :

$varName         // valid
$_varName       // valid
$__varname    // valid
$var_name       // valid
$varName21     // valid
$_var-Name  // invalid contains non alphanumeric character (-)
$_9Var  // invalid - underscore must be followed by a letter
$99Var   // invalid - must begin with a letter or underscore
5 .
What is the difference between $var and $$var?
They are both variables. But $var is a variable with a fixed name. $$var is a variable who's name is stored in $var. For example, if $var contains "message", $$var is the same as $message.
6 .
What are the different types of PHP variables ?
PHP has a total of eight data types which we use to construct our variables  :

Arrays : are named and indexed collections of other values. An array stores multiple values in one single variable.

Booleans : Booleans are the easiest type. A boolean expresses a truth value. It can be either TRUE or FALSE.

Floating - Floating point numbers ("floats", "doubles" or "real numbers") 

Integers : An integer data type is a number of -2, -1, 0, 1, 2, ... Integers can be specified in decimal (10-based), hexadecimal (16-based) or octal (8-based) 

notation, optionally preceded by a sign (- or +).

Objects : To initialize an object, you use the new statement to instantiate the object to a variable.

Resources : A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions.

Doubles : are floating-point numbers, like 3.14159 or 49.1.

Strings  : A string is sequence(series) of characters. where every character is the same as a byte.

A string literal can be specified in three different ways.

single quoted : 'Hello world!'
double quoted : "Hello world!"
heredoc syntax : strings is by using heredoc syntax ("<<<").

NULL : The NULL is a special data type. NULL value represents that a variable has no value. NULL is the only possible value of type NULL.
7 .
How to include a file to a php page ?
We can include a file using "include() " or "require()" function with file path as its parameter.

Syntax : <?php include('css-files.php'); ?>
8 .
What's the difference between include and require ?
If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be  issued, but execution will continue.
9 .
What is php constants ?
A constant is a name or an identifier for a simple value. A constant value cannot change during the execution of the script.  A constant name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

PHP constant : define() 
Let's see the syntax of define() function in PHP.

define(name, value, case-insensitive)

name : specifies the constant name
value : specifies the constant value
case-insensitive : Default value is false. It means it is case sensitive by default.
10 .
What is php strings ?
A string is sequence(series) of characters. where every character is the same as a byte. i.e. used to store and manipulate text.

A string literal can be specified in three different ways.

single quoted : 'Hello world!'
double quoted : "Hello world!"
heredoc syntax : strings is by using heredoc syntax ("<<<").