PHP - RAQ (Rarely Asked Questions!)

Post on 15-Feb-2017

795 views 0 download

Transcript of PHP - RAQ (Rarely Asked Questions!)

/* Question No: 1 */What will be the output?

echo 0123 + 2;

/* Print result */

85

/* Question No: 2 */What will be the output?

print <<<Sania"‘Team, Learn PHP!'"Sania;

/* Print result */

"‘Team, Learn PHP!'"

/* Question No: 3 */What will be the output?

if('10 out of 10' == 10) {echo 'equals to 10';

}else {

echo 'not equals to 10';}

/* Print result */

equals to 10

/* Question No: 4 */What will be the output?

echo (int) ((0.1 + 0.7) * 10);

/* Print result */

7

/* Question No: 5 */What will be the output?

echo 'Testing ' . 1 + 2 . '45';

/* Print result */

245

/* Question No: 6 */What will be the output?

$num = 10;

function multiply(){ $num = $num * 10;}

multiply();

echo $num;

/* Print result */

10

/* Question No: 7 */What will be the output?

function myfunc($argument) {

echo $argument + 10;

}

$variable = 10;

echo "myfunc($variable) = " . myfunc($variable);

/* Print result */

20myfunc(10) =

/* Question No: 8 */What will be the output?

$date = '07/09/2008';

print ereg_replace("([0-9]+)/([0-9]+)/([0-9]+)","\\2/\\1/\\3", $date);

/* Print result */

09/07/2008

/* Question No: 9 */What will be the output when we run the below files (if no_file.php does not exist in the server)?

/* use_include.php */

include('no_file.php');print 'This code will print on the page';

/* use_require.php */

require('no_file.php');print 'This code will print on the page';

/* Print result */

1. will throw warning & print the statements2. will throw fatal error & does not print the statement

/* Question No: 10 */What will be the output?

$a = array ('zero','one','two');

foreach ($a as &$v) {}

foreach ($a as $v) {}

print_r ($a);

/* Print result */

Array ( [0] => zero [1] => one [2] => one )

/* Results… */

If you answered correctly for more than 6 questions…

/* Print result */

Your understanding level in PHP is VERY GOOD!

Suresh Psureshp@angleritech.com