Val Val - 7 months ago 21
PHP Question

Object.hasOwnProperty.call(object, key) in php

Is there an equivalent of this JavaScript code in PHP?

var object = {}, key;
Object.hasOwnProperty.call(object, key)

Answer

for properties:

property_exists($class_instance, 'YourProperty');

for methods:

method_exists($class_instance, 'YourMethod');

http://php.net/manual/en/function.property-exists.php

http://php.net/manual/en/function.method-exists.php

Comments