aptitude
This section contains Aptitude Questions and Answers on PHP Numbers.
本节包含有关PHP数字的能力问题。
Correct answer: 1
Yes
Yes, PHP supports automatic type conversion.
Correct answer: 1
is_int()
The is_int() function is used to check a variable contains an integer number.
正确答案:1
is_int()
is_int()函数用于检查包含整数的变量。
<?php
$num = 1234;
var_dump(is_integer($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
<?php
$num = 1234;
var_dump(is_integer($num));
$num = 12.34;
var_dump(is_integer($num));
?>
Correct answer: 3
bool(true) bool(false)
The above code will print "bool(true) bool(false)" on the webpage.
正确答案:3
bool(true)bool(false)
上面的代码将在网页上打印“ bool(true)bool(false)” 。
Correct answer: 4
is_short()
The is_short() function is not available in PHP.
Correct answer: 3
is_longdouble()
The is_longdouble() function is not available in PHP.
正确答案:3
is_longdouble()
is_longdouble()函数在PHP中不可用。
<?php
$num = 12.34;
var_dump(is_double($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
<?php
$num = 12.34F;
var_dump(is_double($num));
?>
Correct answer: 3
Error
The above code will generate an error.
<?php
$num = 12.34;
var_dump(is_float($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
<?php
define("COUNTRIES", ["INDIA","AUSTRALIA","USA"]);
echo COUNTRY[1];
?>
Correct answer: 1
Yes
Yes, the is_float() function is alias of is_double() function in PHP.
is_finite()
is_infinite()
isfinite()
isinfinite()
Options:
Correct answer: 3
A and B
The is_finite() and is_infinite() functions are used to check numbers infinity in PHP.
is_finite()
is_infinite()
isfinite()
isinfinite()
选项:
正确答案:3
A和B
is_finite()和is_infinite()函数用于检查PHP中的数字无穷大。
<?php
$num = 1234;
var_dump(is_nan($num));
?>
Correct answer: 2
bool(false)
The above code will print "bool(false)" on the webpage.
正确答案:2
布尔值(false)
上面的代码将在网页上打印“ bool(false)” 。
<?php
$num = "ABC";
var_dump(is_numeric($num));
?>
Correct answer: 2
bool(false)
The above code will print "bool(false)" on the webpage.
正确答案:2
布尔值(false)
上面的代码将在网页上打印“ bool(false)” 。
<?php
$num = "123";
var_dump(is_numeric($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
<?php
$num = "123.45";
var_dump(is_numeric($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
int
integer
intval
int_val
Options:
Correct answer: 3
A, B, and C
The int, integer, and intval are used for type conversion in PHP.
整型
整数
间隔
int_val
选项:
正确答案:3
A,B和C
int , integer和intval用于PHP中的类型转换。
<?php
$num1 = "123";
$num2 = int($num1);
echo $num2;
?>
Correct answer: 3
Error
The above code will generate a syntax error.
<?php
$num1 = "123";
$num2 = intval($num1);
echo $num2;
?>
Correct answer: 1
123
The above code will print "123" on the webpage.
<?php
$num1 = "123";
$num2 = integer($num1);
echo $num2;
?>
Correct answer: 3
Error
The above code will generate a syntax error.
<?php
$num1 = "123";
$num2 = (integer)$num1;
echo $num2;
?>
Correct answer: 1
123
The above code will print "123" on the webpage.
<?php
$num1 = "ABC";
$num2 = (int)$num1;
echo $num2;
?>
Correct answer: 2
0
The above code will print "0" on the webpage.
<?php
$num1 = "ABC";
$num2 = intval($num1);
echo $num2;
?>
Correct answer: 2
0
The above code will print "0" on the webpage.
<?php
$num = "123" + 45;
var_dump(isnumeric($num));
?>
Correct answer: 3
Error
The above code will generate a syntax error.
<?php
$num = "123" + 45;
var_dump(is_numeric($num));
?>
Correct answer: 1
bool(true)
The above code will print "bool(true)" on the webpage.
<?php
$num = "ABC";
var_dump(is_nan($num));
?>
Correct answer: 4
None of the above
The above code will print "NULL" on the webpage.
翻译自: https://www.includehelp.com/php/numbers-aptitude-questions-and-answers.aspx
aptitude