1.  What will be the output of the following PHP code ?
function calc($price, $tax=‘‘‘‘)
{
$total = $price + ($price * $tax);
echo ‘‘$total’‘;
}
calc(42);
?


Error
0.
42
84


Answer

 Option

You can designate certain arguments as optional by placing them at the end of the list and assigning them a default value of nothing.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

2.  Which one of the following functions can be used to compress a string ?


zip_compress()
zip()
compress()
gzcompress()


Answer

 Option

We will be able to achieve almost 50% size reduction using this function. The gzuncompress() function is used to uncompress the string.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

3.  Which of the following PHP functions can be used to get the current memory usage ?


get_usage()
get_peak_usage()
get_memory_usage()
get_memory_peak_usage()


Answer

 Option

We can use the memory_get_usage() function, and to get the highest amount of memory used at any point, we can use the memory_get_peak_usage() function.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

4.  Type Hinting was introduced in which version of PHP ?


PHP 4
PHP 5
PHP 5.3
PHP 6


Answer

 Option

Type hinting gives you the ability to force parameters to be objects of certain class or to be arrays. PHP 5 introduced this feature.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

5.  What will be the output of the following PHP code ?
function a()
{
function b()
{
echo 'I am b';
}
echo 'I am a';
}
a();
a();
?>


I am b
I am bIam a
Error
I am a Error


Answer

 Option

This will be the output- I am a Fatal error: Cannot redeclare b()

Workspace

Report
Mail id: Report Error:

Answer Workspace Report