PHP Coding Questions and Answers – Functions – 6

This set of PHP Question Paper focuses on “Functions – 6”. 1. What will be the output of the following PHP code? <?phpfunction colour(){ $colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { echo "$value <br>"; }}colour();?> a) red green blue yellow b) green blue yellow red c) red blue yellow green d) … Read more

advertisement

PHP Coding Questions and Answers – Functions – 5

This set of PHP Assessment Questions and Answers focuses on “Functions – 5”. 1. What will be the output of the following PHP code? <?php $x = 75;$y = 25; function addition(){ $GLOBALS[’z’] = $GLOBALS[’x’] + $GLOBALS[’y’];}addition();echo $z;?> a) 100 b) error c) 75 d) 25 2. What will be the output of the following … Read more

advertisement

PHP Coding Questions and Answers – Functions – 4

This set of PHP Questions and Answers for Aptitude test focuses on “Functions – 4”. 1. What will be the output of the following PHP code? <?php function A1($x) { switch($x) { case 1: //this statement is the same as if($x == 1) echo ‘Case 1 was executed.’; break; case 2: //this statement is the … Read more

advertisement

PHP Coding Questions and Answers – Functions – 3

This set of Advanced PHP Questions and Answers focuses on “Functions – 3”. 1. What will be the output of the following PHP code? <?php $title = "O’malley wins the heavyweight championship!"; echo ucwords($title);?> a) O’Malley Wins The Heavyweight Championship! b) O’malley Wins The Heavyweight Championship! c) O’Malley wins the heavyweight championship! d) o’malley wins … Read more

advertisement

PHP Coding Questions and Answers – Functions – 2

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Functions – 2”. 1. What will be the output of the following PHP code? <?php function sum($num1, $num2) { $total = $num1 + $num2; echo "chr($total)"; } $var1 = "sum"; $var1(5, 44); ?> a) Error b) 49 c) 1 d) Sum 2. What … Read more

advertisement

PHP Coding Questions and Answers – Functions – 1

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Functions – 1”. 1. What will be the output of the following PHP code? <?php function calc($price, $tax="") { $total = $price + ($price * $tax); echo "$total"; } calc(42); ?> a) Error b) 0 c) 42 d) 84 2. What will be … Read more

advertisement

PHP Coding Questions and Answers – For Loops – 3

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “For Loops – 3”. 1. What will be the output of the following PHP code? <?phpfor ($i = 0; 0; $i++) { print"i";}?> a) infinite loop b) 0 c) no output d) error 2. What will be the output of the following PHP … Read more

advertisement

PHP Coding Questions and Answers – For Loops – 2

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “For Loops – 2”. 1. What will be the output of the following PHP code? <?phpfor ($x = 1; $x < 10; $x++) for ($y = 1; $y < 5; $y++) print "Hello";?> a) Hello….36 times b) Hello….45 times c) Hello….50 times d) … Read more

advertisement

PHP Coding Questions and Answers – For Loops – 1

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “For Loops – 1”. 1. What will be the output of the following PHP code? <?php$i = 0;for ($i){ print $i;}?> a) 0 b) infinite loop c) no output d) error 2. What will be the output of the following PHP code? <?php$colors … Read more

advertisement

PHP Coding Questions and Answers – While Loops – 2

This set of Tricky PHP Interview Questions & Answers focuses on “While Loops – 2”. 1. What will be the output of the following PHP code? <?php$i = 0;while($i = 10){ print "hi";}print "hello";?> a) hello b) infinite loop c) hihello d) error 2. What will be the output of the following PHP code? <?php$i … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.