Monday 24 December 2018

Interview Questions for Fresher Set-7

61) 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.

62) 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.

63) How can we determine whether a variable is set?
The boolean function isset determines if a variable is set and is not NULL.

64) 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.

65) What does the expression Exception::__toString means?
Exception::__toString gives the String representation of the exception.

66) 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.

67) 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.

68) 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.

69) 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).
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.

70) What are the two main string operators?
The first is the concatenation operator ('.'), which returns the concatenation of its right and left arguments. The second is ('.='), which appends the argument on the right to the argument on the left.



No comments:

Post a Comment