redefine constant in extended class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mlecho
Forum Commoner
Posts: 53
Joined: Wed Feb 02, 2005 9:59 am

redefine constant in extended class

Post by mlecho »

hi. i am extending a class that has a regex 'define' 'd in the parent class. I am wondering how i can 'redefine' that constant in my new class....is that possible? If so, is that correct below? Does not seem to be...

Code: Select all

 
define('VALID_EMAIL', "/regex_stuff/");
class ParentClass 
{
//class stuff
}
 
define('VALID_EMAIL', "/different_regex_stuff/");
class ChildClass extends ParentClass
{
//do similar stuff
}
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: redefine constant in extended class

Post by php_east »

fortunately constants cannot be redefined. they would'nt be constants if so.
Post Reply