PHP MCQ Questions and Answers
PHP MCQ Questions with Answers help candidates strengthen their programming fundamentals and web development logic through objective-style practice. These PHP programming questions and answers are essential for cracking technical interviews and online coding assessments conducted by top recruiters like TCS, Infosys, Cognizant, and Wipro. Each question tests key PHP concepts such as syntax, data types, arrays, functions, form handling, and error management. Practicing these programming MCQs not only enhances problem-solving speed but also builds confidence for real-time technical evaluations. Whether you are preparing for placement drives, semester exams, or web development roles, this PHP MCQ collection with explanations and solutions PDF will help you master PHP efficiently. Begin your programming test practice online now and ace your upcoming PHP interview round.
PHP MCQ
101. what is the return value of this substr function? <?php $rest = substr("abcdef", -1); $rest = substr("abcdef", 0, -1); ?>
- f,abcde
- a,fedcb
- b,abcdef
- a,abcde
102. Assume that your php file 'index.php' in location c:/apache/htdocs/phptutor/index.php. If you used basename($_SERVER['PHP_SELF']) function in your page, then what is the return value of this function ?
- phptutor
- phptutor/index.php
- index.php
- /index.php
103. $x="display"; ${$x.'_result'} (); ?> Above program will call the function display_result()
- False
- True
- Parser Error
- None of the above
107. $str="3dollars"; $a=20; $a+=$str; print($a); ?> Output ?
- 23dollars
- 203dollars
- 320dollars
- 23
108. <?php function zz(& $x) { $x=$x+5; } ?> $x=10; zz($x); echo $x;
- 5
- 0
- 15
- 10
109. <?php echo $_SERVER['REMOTE_ADDR']; ?>
- shows the IP address of the local system
- shows the IP address of the visitor
- shows the IP address of the webserver
- None of the above
110. <?php $x=dir("."); while($y=$x->read()) { echo $y." " } $y->close(); ?> What is the following output?
- display all folder names
- display a folder content
- display content of the all drives
- Parse error