jamesishereto
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by jamesishereto
-
-
Hi.
I was wondering if there is any way in the given example below for the original display function to still perform the same function but using the redefined constant from the second class?
Thanks,
James
[code]
class A {
const MYCONST = 'abc';
function display() {
echo A::MYCONST;
}
}
class B extends A {
const MYCONST = 'def';
}
[/code]
PHP5 OOP Constants + Help Needed
in PHP Coding Help
Posted
This code gets me what I need but is there a more sensible way to do so?
[code]
<?php
class A {
protected $value = 'Original';
function display() {
echo $this->value;
}
}
class B extends A {
protected $value = 'Contemporary';
}
$B = new B();
$B->display();
?>
[/code]