13.4. Compatibility Mode

In an earlier section, one suggested solution was to turn on the compatibility mode. This mode actually changes more behavior than just the pass-by-reference behavior. It also affects other Zend Engine 2 (PHP 5) related changes. Turning on Zend Engine 1 (PHP 4) compatibility mode changes the following:

  • Passing objects to a function results in a copy of the object (discussed in the previous section).

  • Casting an object to a Boolean, integer, or double results in 0 if the object has no properties.

  • Comparing objects results in true when the properties of the two objects have the same content.

13.4.1. Casting Objects

In PHP 4, (int) $object returns 1 if the object has properties or 0 if the object has no properties. This is ...

Get PHP 5 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.