Home »
Aptitude Questions and Answers »
PHP Aptitude Questions and Answers
PHP Numbers Aptitude Questions and Answers
PHP Numbers Aptitude Questions and Answers: This section contains aptitude questions and answers on PHP Numbers.
By Nidhi Last updated : December 15, 2023
This section contains Aptitude Questions and Answers on PHP Numbers.
1) PHP supports automatic type conversion?
- Yes
- No
Correct answer: 1
Yes
Yes, PHP supports automatic type conversion.
2) Which of the following function is used to check a variable contains an integer number?
- is_int()
- isint()
- isinteger()
- None of the above
Correct answer: 1
is_int()
The is_int() function is used to check a variable contains an integer number.
3) What is the correct output of the given code snippets?
<?php
$num = 1234;
var_dump(is_integer($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
4) What is the correct output of the given code snippets?
<?php
$num = 1234;
var_dump(is_integer($num));
$num = 12.34;
var_dump(is_integer($num));
?>
- bool(true)
- bool(false)
- bool(true) bool(false)
- Error
Correct answer: 3
bool(true) bool(false)
The above code will print "bool(true) bool(false)" on the webpage.
5) Which of the following function is not available in PHP?
- is_int()
- is_integer()
- is_long()
- is_short()
Correct answer: 4
is_short()
The is_short() function is not available in PHP.
6) Which of the following function is not available in PHP?
- is_float()
- is_double()
- is_longdouble()
- is_integer()
Correct answer: 3
is_longdouble()
The is_longdouble() function is not available in PHP.
7) What is the correct output of the given code snippets?
<?php
$num = 12.34;
var_dump(is_double($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
8) What is the correct output of the given code snippets?
<?php
$num = 12.34F;
var_dump(is_double($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 3
Error
The above code will generate an error.
9) What is the correct output of the given code snippets?
<?php
$num = 12.34;
var_dump(is_float($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
10) The is_float() function is alias of is_double() function in PHP?
<?php
define("COUNTRIES", ["INDIA","AUSTRALIA","USA"]);
echo COUNTRY[1];
?>
- Yes
- No
Correct answer: 1
Yes
Yes, the is_float() function is alias of is_double() function in PHP.
11) Which of the following functions are used to check numbers infinity in PHP?
- is_finite()
- is_infinite()
- isfinite()
- isinfinite()
Options:
- Only A
- Only B
- A and B
- C and D
Correct answer: 3
A and B
The is_finite() and is_infinite() functions are used to check numbers infinity in PHP.
12) What is the correct output of the given code snippets?
<?php
$num = 1234;
var_dump(is_nan($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 2
bool(false)
The above code will print "bool(false)" on the webpage.
13) What is the correct output of the given code snippets?
<?php
$num = "ABC";
var_dump(is_numeric($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 2
bool(false)
The above code will print "bool(false)" on the webpage.
14) What is the correct output of the given code snippets?
<?php
$num = "123";
var_dump(is_numeric($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
15) What is the correct output of the given code snippets?
<?php
$num = "123.45";
var_dump(is_numeric($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
16) Which of the following are used for type conversion in PHP?
- int
- integer
- intval
- int_val
Options:
- A and B
- A and C
- A, B, and C
- A, B, C, and D
Correct answer: 3
A, B, and C
The int, integer, and intval are used for type conversion in PHP.
17) What is the correct output of the given code snippets?
<?php
$num1 = "123";
$num2 = int($num1);
echo $num2;
?>
- 123
- "123"
- Error
- None of the above
Correct answer: 3
Error
The above code will generate a syntax error.
18) What is the correct output of the given code snippets?
<?php
$num1 = "123";
$num2 = intval($num1);
echo $num2;
?>
- 123
- "123"
- Error
- None of the above
Correct answer: 1
123
The above code will print "123" on the webpage.
19) What is the correct output of the given code snippets?
<?php
$num1 = "123";
$num2 = integer($num1);
echo $num2;
?>
- 123
- "123"
- Error
- None of the above
Correct answer: 3
Error
The above code will generate a syntax error.
20) What is the correct output of the given code snippets?
<?php
$num1 = "123";
$num2 = (integer)$num1;
echo $num2;
?>
- 123
- "123"
- Error
- None of the above
Correct answer: 1
123
The above code will print "123" on the webpage.
21) What is the correct output of the given code snippets?
<?php
$num1 = "ABC";
$num2 = (int)$num1;
echo $num2;
?>
- 123
- 0
- Error
- None of the above
Correct answer: 2
0
The above code will print "0" on the webpage.
22) What is the correct output of the given code snippets?
<?php
$num1 = "ABC";
$num2 = intval($num1);
echo $num2;
?>
- 123
- 0
- Error
- None of the above
Correct answer: 2
0
The above code will print "0" on the webpage.
23) What is the correct output of the given code snippets?
<?php
$num = "123" + 45;
var_dump(isnumeric($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 3
Error
The above code will generate a syntax error.
24) What is the correct output of the given code snippets?
<?php
$num = "123" + 45;
var_dump(is_numeric($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
25) What is the correct output of the given code snippets?
<?php
$num = "ABC";
var_dump(is_nan($num));
?>
- bool(true)
- bool(false)
- Error
- None of the above
Correct answer: 4
None of the above
The above code will print "NULL" on the webpage.