PHP - Function property_exists()


Advertisements


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

ParameterDescription
objectRequired. The tested object
propertyRequired. The name of the property.

Return Value

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 Test {
   public $property;
  
   public foo() { echo($property); }
}

property_exists('Test', 'property');   // will return true
property_exists('Test', 'Property');   // will return false
?> 

php_function_reference.htm

Advertisements