PHP Interview Questions and Answers Set 9

81. What does the array operator ‘===’ means?

$a === $b TRUE if $a and $b have the same key/value pairs in the same order and of the same types.

82. What is the differences between $a != $b and $a !== $b?

!= means inequality (TRUE if $a is not equal to $b) and !== means non-identity (TRUE if $a is not identical to $b).

83. How can we determine whether a PHP variable is an instantiated object of a certain class?

To be able to verify whether a PHP variable is an instantiated object of a certain class we use instanceof.

84. What is the goto statement useful for?

The goto statement can be placed to enable jumping inside the PHP program. The target is pointed by a label followed by a colon, and the instruction is specified as a goto statement followed by the desired target label.

85. what is the difference between  Exception::getMessage and Exception::getLine ?

Exception::getMessage lets us getting the Exception message and Exception::getLine lets us getting the line in which the exception occurred.



86. What does the expression Exception::__toString means?

Exception::__toString gives the String representation of the exception.

87. How is it possible to parse a configuration file?

The function parse_ini_file() enables us to load in the ini file specified in filename, and returns the settings in it in an associative array.

88. How can we determine whether a variable is set?

The boolean function isset determines if a variable is set and is not NULL.

89. What is the difference between the functions strstr() and stristr()?

The string function strstr(string allString, string occ) returns part of allString from the first occurrence of occ to the end of allString. This function is case-sensitive. stristr() is identical to strstr() except that it is case insensitive.

90. what is the difference between for and foreach?

for is expressed as follows:

for (expr1; expr2; expr3)

statement

The first expression is executed once at the beginning. In each iteration, expr2 is evaluated. If it is TRUE, the loop continues and the statements inside for are executed. If it evaluates to FALSE, the execution of the loop ends. expr3 is tested at the end of each iteration.

However, foreach provides an easy way to iterate over arrays and it is only used with arrays and objects.