This function Checks if the object or class has a property.

Syntax: property_exists ( mixed class, string property )

Description:

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

The first Parameter “class” is Required.It specifies a string with the class name or an object of the class to test for.

The second parameter “property” is Required.It specifies the name of the property.

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

Example:
Code:

 

class myClass {
    var $name;
	
}

$obj=new myClass;
if(property_exists('myClass','name'))
{
echo "name property is exist";
}
else
{
echo "name property  is not exist";
}
   

Output:

name property is exist

eXTReMe Tracker