• PHP Video Tutorials

PHP - Function property_exists()



Syntax

property_exists ( $object, $property );

Definition and Usage

This function checks if the given property exists in the specified class (and if it is accessible from the current scope).

Parameters

Sr.No Parameter & Description
1

object(Required)

The helloed object

2

property(Required)

The name of the property.

Return Value

It returns TRUE if the property exists, FALSE if it doesn't exist or NULL in case of an error.

Example

Following is the usage of this function −

<?php
   class hello {
      public $property;
      public f1() { echo($property); }
   }
   property_exists('hello', 'property');   
   property_exists('hello', 'Property');  
?> 
php_function_reference.htm
Advertisements