Do you have an interview with a hiring manager for a "PHP Developer" position? Are you worried about what will you be asked in the interview? Even if you're just studing for a test or you're an autodidact trying to master PHP, you should review the top 25 PHP interview questions and their answers.
require() will cause E_COMPILE_ERROR which is a fatal error and the script will stop.
include() will only cause E_WARNING which is a warning and the script will continue.
include_once() statements are used when you need to include a file more than once. If it is found that the file has already been included, calling script is going to ignore further fatal errors or warnings respectively.
explode() splits a given string into array by string.
preg_split() splits a string by using a regular expression.
str_split() converts a given string to an array.
ksort() function sorts an associative array according to the key in ascending order.
krsort() function sorts an associative array according to the key in descending order.
asort() function sorts an associative array according to the value* in ascending order.
arsort() function sorts an associative array according to the value in descending order.
The magic methods (or functions) begin with two underscores (__) and have special names. These methods are invoked by particular events. PHP calls the function instead of the coder and provides more functionality. Magic methods are:
$$var are both variables. The first one is a normal variable, and the second one is a reference variable.
$var has a fixed name, while the name of
$$var is stored in
htmlentities()converts all possible characters to HTML entities.
htmlspecialchars()converts only predefined characters to HTML entities.
Notices: These are non-critical errors which occur during executing a script. These errors are not displayed to the user by default. For example, trying to call an undefined variable.
Warnings: These are serious errors which are displayed to the user, but don't cause script termination. For example, trying to call a non-existent file.
Fatal errors: These are critical errors which cause the termination of the script. For example, trying to call a non-existent function.
Numeric array is an array that uses numeric index. Values are stored in a linear way.
Associative array is the array in which the keys are strings.
Multidimensional array is an array which contains one or more arrays. The values can be accessed by multiple indices.
getenv()function provides access to the value of all environment variables.
$_REQUEST variable contains
$_REQUEST can be used to get form data sent with
The array operator checks the variables on the left and the right side, whether they have the same key-values in the same order and they are of the same types.
preg_match() function searches the given string for a required pattern, returning true if the pattern exists, or false, otherwise.
preg_split() function uses regular expressions as input parameters for a pattern. It operates like
In a child class, the definition of a function which is inherited from parent class can be changed by overriding.
final keyword prevents the child class from overriding a method. If the class is defined
final, then it can not be extended.
The seven methods are:
Answer: no output
$_SERVER['PHP_SELF'] is a variable that returns the filename of the current script.
Array (  => Array (  => William  => Avarel)  => Jack  => Joe)
A session is started by calling
session_start() function. This function checks if a session has already started. If not, it starts one.
In conclusion, these PHP questions are some of the most asked questions in interviews worldwide, but it doesn't mean that's all. You should continue to review and you might want to continue reading some interesting questions with their answers here. If you think there are more questions that should be included in this list, please, share in the comments below.