PHP Multiple choices


Total available count: 47
Subject - PHP Frameworks
Subsubject - PHP

How can we test if two objects are referring to the same instance of the same class in PHP?


 

 

 

 



B


Solution:-

The identity operator (===) allows for a much stricter comparison between the given variables or values. This operator returns true if both variable contains same information and same data types otherwise return false.

Object variables are compared in a simple manner when using the comparison operator (==), namely: Two object instances are equal if they have the same attributes and values (values are compared with ==) and are instances of the same class.

When using the identity operator (===), object variables are identical if and only if they refer to the same instance of the same class.

An example will clarify these rules.

Following is the example of object comparison:

<php
function bool2str($bool)
{
  if ($bool === false) {
    return 'FALSE';
  } else {
    return 'TRUE';
  }
}
>

 




Next 4 multiple choice(s)

1

All variables in PHP start with which symbol?

2

How do you write "WELCOME" in PHP?

3

PHP server scripts are surrounded by delimiters, which?

4

What does PHP stand for?

Comments