Which “false” is it?

dionyziz@turing ~ $ cat test.php
<?php
    class false {
    }
 
    $c = New false();
    echo get_class( $c );
?>
 
dionyziz@turing ~ $ php test.php
false
dionyziz@turing ~ $

4 Responses to “Which “false” is it?”

  1. abresas Says:

    the one you created, as get_class( false ) does not return “false”

    and $c = New false(); would be a fatal error if you did not
    declare your own false class

  2. dionyziz Says:

    Obviously, but that’s still kinda weird that it allows me to declare such a class, don’t you think?

  3. agorf Says:

    “true” and “false” are not reserved words in PHP. They are globally-defined constants according to PHP.net.

    http://www.php.net/manual/en/reserved.php

  4. Indy Says:

    Neither in Python, “True” and “False” are reserved keywords. They are just two predefined variables, whose value can change during runtime, or new classes can be defined with their names, etc.

Leave a Reply