PHP Numbers Aptitude Questions and Answers

PHP Numbers Aptitude Questions and Answers: This section contains aptitude questions and answers on PHP Numbers.
Submitted by Nidhi, on May 23, 2020

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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.