Should'nt this work? Currently it reports an error about a undefined constant.
<?
class Test {
const FOO = 100;
var $bar = FOO;
}
$Test = new Test;
echo $Test->bar;
?>
Ciao,
Arjen
"Arjen Brouwer" arjenjb@quicknet.nl escreveu na mensagem
news:001b01c368a1$775b2070$6402a8c0@sleepert...
Should'nt this work? Currently it reports an error about a undefined
constant.<?
class Test {
const FOO = 100;
var $bar = FOO;
}$Test = new Test;
echo $Test->bar;
?>Ciao,
Arjen
IMHO it should.
Cristiano Duarte.
At 14:35 22/08/2003, Arjen Brouwer wrote:
Should'nt this work? Currently it reports an error about a undefined constant.
<?
class Test {
const FOO = 100;
var $bar = FOO;
Should be var $bar = Test::FOO (or self::FOO, even though it appears not to
work right now) - there's no implicit class/object dereference of any kind
in PHP.
Zeev
Wait a sec... When did const become a keyword? And since when can you
initialize variables from outside a constructor/function?
Sorry to bother..
--
// DvDmanDT
MSN: dvdmandt@hotmail.com
Mail: dvdmandt@telia.com
"Zeev Suraski" zeev@zend.com skrev i meddelandet
news:5.1.0.14.2.20030823012845.0576f768@localhost...
At 14:35 22/08/2003, Arjen Brouwer wrote:
Should'nt this work? Currently it reports an error about a undefined
constant.<?
class Test {
const FOO = 100;
var $bar = FOO;Should be var $bar = Test::FOO (or self::FOO, even though it appears not
to
work right now) - there's no implicit class/object dereference of any kind
in PHP.Zeev
At 07:03 23/08/2003, DvDmanDT wrote:
Wait a sec... When did const become a keyword?
In PHP 5.0.
And since when can you
initialize variables from outside a constructor/function?
Since PHP 3.0 :)
Zeev
Zeev,
speaking of const, i have a feature request. why not accept "const" in
the global context and create a compile-time global constant ?
e.g.
const FOO = 1 ;
const BAR = 2;
class Barbara {
const Barbara::BUSH = FOO;
};
i'd much prefer this as an alternative to the runtime define().
l0t3k
"Zeev Suraski" zeev@zend.com wrote in message
news:5.1.0.14.2.20030823170950.05b14e30@localhost...
At 07:03 23/08/2003, DvDmanDT wrote:
Wait a sec... When did const become a keyword?
In PHP 5.0.
And since when can you
initialize variables from outside a constructor/function?Since PHP 3.0 :)
Zeev
At 20:40 23/08/2003, l0t3k wrote:
Zeev,
speaking of const, i have a feature request. why not accept "const" in
the global context and create a compile-time global constant ?
e.g.const FOO = 1 ; const BAR = 2; class Barbara { const Barbara::BUSH = FOO; };i'd much prefer this as an alternative to the runtime
define().
It's going to be runtime either way, because you could do if (...) { const
FOO = 1; } else {const FOO = 2 }. Not sure if we want it as syntactic
sugar for define() or not.
Zeev
- Thus wrote Zeev Suraski (zeev@zend.com):
At 20:40 23/08/2003, l0t3k wrote:
Zeev,
speaking of const, i have a feature request. why not accept "const" in
the global context and create a compile-time global constant ?
e.g.const FOO = 1 ;
const BAR = 2;class Barbara {
const Barbara::BUSH = FOO;
};i'd much prefer this as an alternative to the runtime
define().It's going to be runtime either way, because you could do if (...) { const
FOO = 1; } else {const FOO = 2 }. Not sure if we want it as syntactic
sugar fordefine()or not.
This would be nice! Id like to add perhaps, but not sure how hard
it would be, to make this constant (aliased define) unchangeable
through out the life time of the script.
Curt
"I used to think I was indecisive, but now I'm not so sure."