Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function property_exists()


previous

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).

Paramters

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
?> 

previous Printer Friendly

Advertisements


  

Advertisements