Page 1 of 1

define constants in class

Posted: Thu Mar 18, 2004 6:30 pm
by allelopath
This is ok:

<?php
define ("HOME_BTN", "Home");
class Menu
{
}
?>

This is not
<?php
class Menu
{
define ("HOME_BTN", "Home");
}
?>

It won't let me define a constant class member.
(gives a parse error on the define line)
Why?

Posted: Fri Mar 19, 2004 10:03 am
by EvilWalrus
Class constants are available in PHP5, but not in PHP4...

Code: Select all

<?php

class foo
{
    public const bar = 'baz';

    ...
}

?>

Posted: Fri Mar 19, 2004 11:08 am
by allelopath
darn, it looks like there's many Java like things in PHP5,
but i cannot upgrade

Posted: Fri Mar 19, 2004 1:04 pm
by PrObLeM
PHP 5 Release Candidate 1 Released! [18-Mar-2004]