• PHP Video Tutorials

PHP - is_object() Function


Advertisements

Definition and Usage

The function is_object() verifies whether a variable is an object.

Syntax

bool is_object ( mixed $value )

Parameters

Sr.No Parameter Description
1

value

The variable being evaluated.

Return Values

This function returns true if value is a number or a numeric string, false otherwise. Since PHP 7.2: This function now returns true for unserialized objects without a class definition. Earlier false was returned

Dependencies

PHP 4 and above.

Example

Following example demonstrates return values with different types of variables:

<?php
  // Create a class
  class tutorialsPoint {
      public $tp_name =
            "Welcome to TutorialsPoint";
  }

  // Create the class name alias
  class_alias('tutorialsPoint', 'TP');

  $obj1 = new tutorialsPoint();
  $obj2 = new TP();
  $obj3 = 'TutorialsPoint';

  var_dump(is_object($obj1));
  var_dump(is_object($obj2));
  var_dump(is_object($obj3));
?>

Output

This will produce following result −

bool(true)
bool(true)
bool(false)

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements