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?
  1. Yes
  2. No

2) Which of the following function is used to check a variable contains an integer number?
  1. is_int()
  2. isint()
  3. isinteger()
  4. None of the above

3) What is the correct output of the given code snippets?
<?php
$num = 1234;
var_dump(is_integer($num));
?>
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

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));
?>
  1. bool(true)
  2. bool(false)
  3. bool(true) bool(false)
  4. Error

5) Which of the following function is not available in PHP?
  1. is_int()
  2. is_integer()
  3. is_long()
  4. is_short()

6) Which of the following function is not available in PHP?
  1. is_float()
  2. is_double()
  3. is_longdouble()
  4. is_integer()

7) What is the correct output of the given code snippets?
<?php
$num = 12.34;
var_dump(is_double($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

8) What is the correct output of the given code snippets?
<?php
$num = 12.34F;
var_dump(is_double($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

9) What is the correct output of the given code snippets?
<?php
$num = 12.34;
var_dump(is_float($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

10) The is_float() function is alias of is_double() function in PHP?
<?php
define("COUNTRIES", ["INDIA","AUSTRALIA","USA"]);
echo COUNTRY[1];    
?>
  1. Yes
  2. No

11) Which of the following functions are used to check numbers infinity in PHP?
  1. is_finite()
  2. is_infinite()
  3. isfinite()
  4. isinfinite()

Options:

  1. Only A
  2. Only B
  3. A and B
  4. C and D

12) What is the correct output of the given code snippets?
<?php
$num = 1234;
var_dump(is_nan($num));
?>
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

13) What is the correct output of the given code snippets?
<?php
$num = "ABC";
var_dump(is_numeric($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

14) What is the correct output of the given code snippets?
<?php
$num = "123";
var_dump(is_numeric($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

15) What is the correct output of the given code snippets?
<?php
$num = "123.45";
var_dump(is_numeric($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

16) Which of the following are used for type conversion in PHP?
  1. int
  2. integer
  3. intval
  4. int_val

Options:

  1. A and B
  2. A and C
  3. A, B, and C
  4. A, B, C, and D

17) What is the correct output of the given code snippets?
<?php
$num1 = "123";    
$num2 = int($num1);
echo $num2;    
?>  
  1. 123
  2. "123"
  3. Error
  4. None of the above

18) What is the correct output of the given code snippets?
<?php
$num1 = "123";

$num2 = intval($num1);

echo $num2;
?>  
  1. 123
  2. "123"
  3. Error
  4. None of the above

19) What is the correct output of the given code snippets?
<?php
$num1 = "123";

$num2 = integer($num1);

echo $num2;
?>  
  1. 123
  2. "123"
  3. Error
  4. None of the above

20) What is the correct output of the given code snippets?
<?php
$num1 = "123";

$num2 = (integer)$num1;

echo $num2;
?>  
  1. 123
  2. "123"
  3. Error
  4. None of the above

21) What is the correct output of the given code snippets?
<?php
$num1 = "ABC";

$num2 = (int)$num1;

echo $num2;
?>
  1. 123
  2. 0
  3. Error
  4. None of the above

22) What is the correct output of the given code snippets?
<?php
$num1 = "ABC";

$num2 = intval($num1);

echo $num2;
?>  
  1. 123
  2. 0
  3. Error
  4. None of the above

23) What is the correct output of the given code snippets?
<?php
$num = "123" + 45;

var_dump(isnumeric($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

24) What is the correct output of the given code snippets?
<?php
$num = "123" + 45;

var_dump(is_numeric($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

25) What is the correct output of the given code snippets?
<?php
$num = "ABC";

var_dump(is_nan($num));
?>  
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

Learn PHP programming with our PHP tutorial.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.