- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
property_exists() function in PHP
The property_exists() method checks if the object or class has a property.
Syntax
property_exists(object, property)
Parameters
object/ class − The object or the class name
property − The name of the property
Return
The property_exists() function returns TRUE if the property exists, FALSE if it doesn't exist or NULL in case of an error.
Example
The following is an example −
<?php class Demo { public $one; private $two; static protected $VAL; static function VAL() { var_dump(property_exists('myClass', 'two')); } } var_dump(property_exists('Demo', 'one')); var_dump(property_exists(new Demo, 'one')); ?>
Output
The following is the output −
bool(true) bool(true)
Advertisements