Explore topic-wise MCQs in Php.

This section includes 280 Mcqs, each offering curated multiple-choice questions to sharpen your Php knowledge and support exam preparation. Choose a topic below to get started.

101.

Mt_rand ( ) function generates a random integer by using

A. Mersenne Twister algorithm
B. Divide and Conquer algorithm
C. Backtracking algorithm
D. Greedy Algorithm
Answer» B. Divide and Conquer algorithm
102.

PHP does automatic conversion of

A. Functions
B. Numerical types
C. Arrays
D. None of them
Answer» C. Arrays
103.

Mt_rand ( ) function produces a better random value, and is 4 times faster than

A. Assignment function
B. Boolean function
C. Comparison functions
D. rand ( ) function
Answer» E.
104.

Which operators have higher precedence?

A. Arithmetic operators
B. Comparison operators
C. Logical operators
D. Boolean operators
Answer» B. Comparison operators
105.

A simple mathematical function in PHP that takes a single argument and returns nearest integer, is a

A. round ( )
B. abs ( )
C. max ( )
D. floor ( )
Answer» B. abs ( )
106.

How many numerical types are allowed in PHP?

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
107.

Decrement operator is denoted by

A. ++
B. −−
C. %%
D. ⁄⁄
Answer» C. %%
108.

A simple mathematical function in PHP that takes a single argument and returns largest integer that is less than or equal to that argument, is a

A. ceil ( )
B. abs ( )
C. max ( )
D. floor ( )
Answer» E.
109.

Numerical type in PHP is integer and

A. Strings
B. Unsigned short integer
C. Single-precisions
D. Double
Answer» E.
110.

Example of random number function is/are

A. strand ( )
B. getrandmax ( )
C. mt_rand ( )
D. All of them
Answer» E.
111.

Floating point numbers is also known as

A. long
B. Integers
C. Double
D. Character
Answer» D. Character
112.

Integers are also known as

A. Short integers
B. Double
C. floating point numbers
D. long
Answer» E.
113.

PHP will automatically convert strings to numbers when it needs to.~!

A. TRUE
B. FALSE
Answer» B. FALSE
114.

The result of below two statements will be:Round(2.5)Round(-2.5)~!

A. 2.5, -2
B. 2, -2
C. 3, -3
D. 3.5, -3.5
Answer» D. 3.5, -3.5
115.

If you do something to an integer that makes it larger than the maximum allowable integer or smaller than the minimum possible integer, the PHP interpreter converts the result into a . . . . .¬¨‚Ä~!

A. String
B. Floating point number
C. Integers
D. None of above
Answer» C. Integers
116.

In PHP the integer 45 is stored exactly as 45. The floating point number 46.3 could be stored as.%!

A. 46
B. 46.3
C. 46.2999999
D. none of above
Answer» D. none of above
117.

Ceil(-2.1) would be%!

A. 3
B. -3
C. -2
D. 2
Answer» D. 2
118.

PHP can automatically convert integers to floating point numbers and floating point numbers to integers.%!

A. TRUE
B. FALSE
Answer» B. FALSE
119.

Numbers in PHP can’t be infinitely large or small, there is some minimum and maximum size. If more larger (or smaller) numbers are needed then . . . . . must be used:1. GPM libraries2. GMP libraries3. CBMath4. BCMath%!

A. Option 2 and 4
B. Option 3 and 4
C. Option 1 and 4
D. Option 2 and 3
Answer» B. Option 3 and 4
120.

What will be the output of the following PHP code ?%!

A. qwe12345rty
B. qwe$arty
C. qwe
D. error
Answer» D. error
121.

The result of both the below expressions in PHP will be same:1) 3+4*22) (3+4)*2%!

A. TRUE
B. FALSE
Answer» C.
122.

What will be the output of the following PHP code ?%!

A. qwe12345rty
B. qwe{$a}rty
C. error
D. no output
Answer» C. error
123.

In order to find if a variable holds an actual number or a string containing characters that can be translated into a number you can use:%!

A. is_num()
B. is_number()
C. if_numeric
D. is_numeric()
Answer» E.
124.

What will be the output of the following PHP code ?%!

A. qwe12345rty
B. qwe$arty
C. error
D. no output
Answer» B. qwe$arty
125.

What is the output of given statement?Print 17 % 3;%!

A. 5.67
B. 2
C. 5.666667
D. none of above
Answer» C. 5.666667
126.

What will be the output of the following PHP code ?%!

A. 1.75
B. 0.875
C. 3.5
D. Error
Answer» C. 3.5
127.

What will be the output of the following PHP code ?%!

A. 0
B. Nothing
C. True
D. Error
Answer» C. True
128.

What will be the output of the following PHP code ?%!

A. Hello World
B. Bye
C. Hello worldBye
D. Error
Answer» B. Bye
129.

What will be the output of the following PHP code ?%!

A. 3
B. 4
C. 6
D. Error
Answer» E.
130.

What will be the output of the following PHP code ?%!

A. test
B. testtest
C. testvalue
D. error, constant value cannot be changed
Answer» D. error, constant value cannot be changed
131.

What will be the output of the following PHP code ?%!

A. $GREETING
B. no output
C. PHP is a scripting language
D. GREETING
Answer» C. PHP is a scripting language
132.

What will be the output of the following PHP code ?%!

A. 0
B. 1
C. 2
D. Error
Answer» C. 2
133.

What will be the output of the following PHP code ?%!

A. red1
B. red 1
C. 0
D. 1
Answer» E.
134.

What will be the output of the following PHP code ?%!

A. red green
B. red
C. green
D. error
Answer» E.
135.

What will be the output of the following PHP code ?%!

A. My car is a Volvo
B. My car is a BMW
C. My car is a Toyota
D. Error
Answer» B. My car is a BMW
136.

What will be the output of the following PHP code ?%!

A. qwe12345rty
B. qwe{$a}rty
C. error
D. no output
Answer» B. qwe{$a}rty
137.

What will be the output of the following PHP code ? ($j - $k));?>%!

A. 1
B. no output
C. error
D. 0
Answer» C. error
138.

What will be the output of the following PHP code ? 0){ $i++; print $i; print "hello";}?>%!

A. 4hello4hello4hello4hello4hello…..infinite
B. 5hello5hello5hello5hello5hello…..infinite
C. no output
D. error
Answer» B. 5hello5hello5hello5hello5hello‚Äö√Ѭ∂..infinite
139.

What will be the output of the following PHP code ? ($y != $y++)){ echo $y;}?>%!

A. 1
B. 0
C. 2
D. no output
Answer» C. 2
140.

What will be the output of the following PHP code ?%!

A. no output
B. true 23
C. true 22
D. true 33
Answer» C. true 22
141.

What will be the output of the following PHP code ?%!

A. 000
B. 012
C. 123
D. Error
Answer» C. 123
142.

What will be the output of the following PHP code ?%!

A. 02
B. 12
C. 01
D. 21
Answer» B. 12
143.

What will be the output of the following PHP code ?%!

A. 20
B. true0
C. 0
D. true20
Answer» C. 0
144.

What will be the output of the following PHP code ? ++$i) - 1){ print $i;}?>%!

A. 00000000000000000000….infinitely
B. -1-1-1-1-1-1-1-1-1-1…infinitely
C. no output
D. error
Answer» B. -1-1-1-1-1-1-1-1-1-1‚Äö√Ѭ∂infinitely
145.

*$_What will be the output of the following PHP code ??

A. 5
B. 10
C. 15
D. Error
Answer» D. Error
146.

*/*_What will be the output of the following PHP code ??

A. 0
B. 1
C. 2
D. Error
Answer» C. 2
147.

*/*_What will be the output of the following PHP code ??

A. test
B. testtest
C. testvalue
D. error, constant value cannot be changed
Answer» D. error, constant value cannot be changed
148.

*/*_What will be the output of the following PHP code ??

A. $GREETING
B. no output
C. PHP is a scripting language
D. GREETING
Answer» C. PHP is a scripting language
149.

*/*_What will be the output of the following PHP code ??

A. My car is a Volvo
B. My car is a BMW
C. My car is a Toyota
D. Error
Answer» B. My car is a BMW
150.

*/*_What will be the output of the following PHP code ??

A. Thiswasabadidea
B. Thiswasbadidea
C. Thiswas a badidea
D. Thiswas abadidea
Answer» C. Thiswas a badidea