âš ī¸ Warning âš ī¸ Deprecated Code! This video tutorial contains outdated code.
💡 If you wish to update it, any AI assistant will update the code for you in seconds.

Using the property_exists Function

Published : November 22, 2014   •   Last Edited : November 24, 2025   •   Author : Adam Khoury
The property_exists() function will evaluate to see if the specified property exists. It returns a value of TRUE if the property is found and FALSE if not. demo.php
<?php
include_once("class1.php");

$myObj = new class1();
if(property_exists($myObj, "age")){
    echo $myObj->age;
}
?>
class1.php
<?php
class class1 {

    public $age = 72;
}
?>