Skip to main content

Functions — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Functions — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
25
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
30 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
25

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/25 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php $var = 10 ; function one () { echo $var; } one () ; ?>

Question 2 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function mine ( $m ) { if ( $m < 0 ) echo "less than 0" ; if ( $ >= 0 ) echo "Not True" ; } mine ( 0 ) ; ?>

Question 3 of 25
★ FPSC ★ PPSC

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; ?>

Question 4 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function 2 myfunc () { echo "Hello World" ; } 2 myfunc () ; ?>

Question 5 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function _func () { echo "Hello World" ; } _func () ; ?>

Question 6 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function test ( $int ) { if ( $int == 1 ) echo "This Works" ; if ( $int == 2 ) echo "This Too Seems To Work" ; } test ( 1 ) ; TEST ( 2 ) ; ?>

Question 7 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function mine ( $num ) { $num = 2 + $num; echo $num; } mine ( 3 ) ; ?>

Question 8 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function movie ( $int ) { $movies = array( "Fight Club", "Kill Bill", "Pulp Fiction" ) ; echo "You Do Not Talk About " . $movie [ $integer ] ; } movie ( 0 ) ; ?>

Question 9 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function time ( $string ) { echo strtr( "Towe Pa55" , "ow5" , $string ) ; } time( "ims" ) ; ?>

Question 10 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function constant () { define ( "GREETING", "Welcome to Narnia" ) ; echo greeting; } ?>

Question 11 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function constant() { define ( "GREETING" , "Welcome to Narnia" , true ) ; echo greeting; } ?>

Question 12 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function start ( $string ) { if ( $string < 45 ) return 20 ; else return 40 ; } $t = start ( 90 ) ; if ( $t < 20 ) { echo "Have a good day!" ; } else { echo "Have a good night!" ; } ?>

Question 13 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function email () { $email = ’contact@examveda.com’; $new = strstr ($email, ‘@'); echo $new; } email(); ?>

Question 14 of 25
★ FPSC ★ PPSC

What will be the output of the following PHP code ? <?php function string () { echo strstr ( "Hello world!" , 111 ) ; } string () ; ?>

Question 15 of 25
★ FPSC ★ PPSC

Which one of the following is the right way of defining a function in PHP?

Question 16 of 25
★ FPSC ★ PPSC

. . . . . converts the keys of an array into values and the values into keys.

Question 17 of 25
★ FPSC ★ PPSC

Above usleep() function pauses PHP for . usleep(1000000);

Question 18 of 25
★ FPSC ★ PPSC

Output will be: $array = array ( 0, 1, 2 ) ; $array = array_pad ( $array, -6, ‘NEW’ ) ;

Question 19 of 25
★ FPSC ★ PPSC

phpinfo() will display about? 1. OS version information 2. PHP installation 3. Variables 4. HTTP headers

Question 20 of 25
★ FPSC ★ PPSC

. . . . returns a new DateTime object.

Question 21 of 25
★ FPSC ★ PPSC

It is always necessary to use parentheses with the print function.

Question 22 of 25
★ FPSC ★ PPSC

The below statement will return. $Var = substr ( ""abcdef"", -4, 1 ) ;

Question 23 of 25
★ FPSC ★ PPSC

Returning values from functions may include .....

Question 24 of 25
★ FPSC ★ PPSC

The arguments in a function are evaluated from .....

Question 25 of 25
★ FPSC ★ PPSC

strlen() returns the length of the string on success and . . . . if the string is empty.

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →