PHP Tutorial

PHP Examples

PHP Practice

PHP Operators Aptitude Questions and Answers

PHP Operators Aptitude Questions and Answers: This section contains aptitude questions and answers on PHP Operators. By Nidhi Last updated : December 15, 2023

This section contains Aptitude Questions and Answers on PHP Operators.

1) Which of the following types of operators are used in PHP?
  1. Arithmetic Operators
  2. Logical Operators
  3. Array Operators
  4. String Operators

Options:

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

2) What is the correct output of the given code snippets?
<?php
$NUM1 = 3;
$NUM2 = 4;

$NUM3 = $NUM1 ** $NUM2;
echo $NUM3;
?>
  1. 12
  2. 81
  3. Garbage value
  4. None of the above

3) The "**" operator belongs to which category of operators?
  1. Arithmetic operator
  2. Logical operator
  3. Comparison operator
  4. Conditional operator

4) Which of the following are comparison operators in PHP?
  1. ==
  2. !=
  3. ===
  4. < = >

Options:

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

5) What is the correct output of given code snippets?
<?php
$NUM1 = 3;
$NUM2 = 4;

var_dump($NUM1 != $NUM2);
?>
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

6) What is the correct output of given code snippets?
<?php
$NUM1 = 3;
$NUM2 = 4;

var_dump($NUM1 !== $NUM2);
?>
  1. bool(true)
  2. bool(false)
  3. Error
  4. None of the above

7) What is the correct output of given code snippets?
<?php
$NUM1 = 3;
$NUM2 = 4;

var_dump($NUM1 <=> $NUM2);
?>
  1. int(0)
  2. int(-1)
  3. int(1)
  4. Error

8) Which of the following operator is not available in PHP?
<?php
$num = "Hello";
var_dump($num);
?>
  1. Dot (.)
  2. =
  3. .=
  4. @

9) What is the correct output of given code snippets?
<?php
echo $country = $country ?? "india";
?>  
  1. india
  2. garbage value
  3. Error
  4. None of the above

10) Which of the following operator is known as null coalescing in PHP?
  1. < == >
  2. ===
  3. ??
  4. ?

Learn PHP programming with our PHP tutorial.

Comments and Discussions!

Load comments ↻





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