Home > PHP > Constant Bite

Constant Bite

It looks like we have to use another compatibility function due to inconsistencies between PHP versions.

For PHP versions below 4.3.5, defined() returns an integer (1 or 0), whereas from 4.3.5 onwards it returns a boolean (true or false).

This makes it impossible for us to use the following:

if (defined('CONSTANT') === true) {
...
}

A note has been added to the PHP documentation page to warn others of this inconsistency.

Relevant bug report:

http://bugs.php.net/bug.php?id=27443

Categories: PHP Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.