PHP Interview Questions
1 .
What is a Database ?
MySQL is a fast, easy to use relational database, it is Initial release date is 23 May 1995.  MySQL is  commonly used in PHP scripts to create powerful and dynamic server-side applications. 
2 .
what is sql injection ?
SQL injection is a malicious code injection technique.It exploiting SQL vulnerabilities in Web applications
3 .
What is difference between include(),require(),include_once() and require_once()?
Include() : Include is used to include files more than once in single PHP script.You can include a file as many times you want.
 
Syntax :
include(“file_name.php”);​
Include Once() : Include once include a file only one time in php script.Second attempt to include is ignored.
 
Syntax :
include_once(“file_name.php”);​
Require() : Require is also used to include files more than once in single PHP script.Require generates a Fatal error and halts the script execution,if file is not found on specified location or path.You can require a file as many time you want in a single script.
 
Syntax :
require(“file_name.php”);​
Require Once() : Require once include a file only one time in php script.Second attempt to include is ignored. Require Once also generates a Fatal error and halts the script execution ,if file is not found on specified location or path.
 
Syntax :
require_once(“file_name.php”);​
4 .
Differences between POST and GET methods?
PHP POST method :

This is the built in PHP super global array variable that is used to get values submitted via HTTP POST method.
The array variable can be accessed from any script in the program; it has a global scope.
This method is ideal when you do not want to display the form post values in the URL.
 
Syntax :
<?php
 $_POST['variable_name'];
?>
 
 
PHP GET method :
 
This is the built in PHP super global array variable that is used to get values submitted via HTTP GET method.
 
The array variable can be accessed from any script in the program; it has a global scope.
 
This method displays the form values in the URL.
 
Syntax :
<?php
$_GET['variable_name'];
?>
 
5 .
Explain isset() function?
The isset() function checks if the particular variable is set and has a value other than NULL. The function returns Boolean – false if the variable is not set or true if the variable is set. The function can check multiple values: isset(var1, var2, var3…)
6 .
How to upload files in PHP?
Firstly, PHP should allow file uploads; this can be done by making the directive file_uploads = On
 
You can then add the action method as 'post' with the encoding type as 'multipart/form-data'.
 
<form action="sample_upload.php"method="post"enctype="multipart/form-data">​


The myupload.php file contains code specific to the fule type to be uploaded, for example, image, document, etc., and details like target path, size, and other parameters.
 
You can then write the HTML code to upload the file you want by specifying the input type as 'file.'
7 .
Explain the Importance of Parser in PHP?
A PHP parser is a software that converts source code that the computer can understand. This means whatever set of instructions we give in the form of code is converted into a machine-readable format by the parser. You can parse PHP code with PHP using the token_get_all function.
8 .
What is cron jobs in PHP?
The App Engine Cron Service allows you to configure regularly scheduled tasks that operate at defined times or regular intervals. These tasks are commonly known as cron jobs. These cron jobs are automatically triggered by the App Engine Cron Service. For instance, you might use a cron job to send out an email report on a daily basis, or to update some cached data every 10 minutes, or refresh summary information once an hour.
 
A cron job makes an HTTP GET request to a URL as scheduled. The handler for that URL executes the logic when it is called. A cron job request is subject to the same limits as those for push task queues.
9 .
Explain Path Traversal?
Path Traversal is a form of attack to read into the files of a web application. ‘../’ is known as dot-dot-sequences. It is a cross-platform symbol to go up in the directory. To operate the web application file, Path Traversal makes use of the dot-dot-slash sequences.
 
The attacker can disclose the content of the file attacked using the Path Traversal outside the root directory of a web server or application. It is usually done to gain access token, secret passwords, and other sensitive information stored in the files.
 
Path Traversal is also known as Directory Traversal. It enables the attacker to exploit vulnerabilities present in the web file under attack.
10 .
How is typecasting achieved in PHP?
The name of the output type needs to be specified in parentheses before the variable that is to be cast. Some examples are :
 
* (array) – casts to array
* (bool), (boolean) – casts to Boolean
* (double), (float), (real) – casts to float
* (int), (integer) – casts to integer
* (object) – casts to object
* (string) – casts to string