Skip to content
Advertisement

How to define an empty object in PHP

with a new array I do this:

JavaScript

Is there a similar syntax for an object

JavaScript

Advertisement

Answer

JavaScript

A comment in the manual sums it up best:

stdClass is the default PHP object. stdClass has no properties, methods or parent. It does not support magic methods, and implements no interfaces.

When you cast a scalar or array as Object, you get an instance of stdClass. You can use stdClass whenever you need a generic object instance.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement