On Sat, 2012-08-25 at 15:17 -0400, Matt Neimeyer wrote:

> Can you just switch the order?
> 
> Instead of...
> 
>    define("SOME_CONSTANT","Generic Value");
>    define("SOME_CONSTANT","Override Value");
> 
> Why not do...
> 
>    define("SOME_CONSTANT","Override Value");
>    if(!defined("SOME_CONSTANT")) { define("SOME_CONSTANT","Generic Value"); }
> 
> This should avoid any redefinition and thus the notices.
> 
> Matt
> 
> On Sat, Aug 25, 2012 at 3:07 PM, Matijn Woudt <tijn...@gmail.com> wrote:
> > Op 25 aug. 2012 21:03 schreef "Adam Richardson" <simples...@gmail.com> het
> > volgende:
> >>
> >> On Sat, Aug 25, 2012 at 2:27 PM, Lester Caine <les...@lsces.co.uk> wrote:
> >> > What I was not expecting was a string of 'Notices:' complaining about
> > the
> >> > redefines. So how does one get around this message? One can't 'if
> > defined'
> >> > as the string needs to be replaced with the more appropriate one. I
> > would
> >> > say, why is this even a problem, or alternatively I just give up on
> > E_STRICT
> >> > and make sure it's disabled again on PHP5.4?
> >> >
> >> > Having spent several months getting the code clean on E_STRICT,
> > switching it
> >> > off again will really pig me off, but I can't see any real alternative
> > given
> >> > the number of languages and strings that will need reworking simply to
> > get
> >> > things clean :(
> >>
> >> Well, I'd do the following to avoid issues in the future.
> >>
> >> 1) Create a function like that below, which provides global access to
> >> variables and allows you to update existing values:
> >>
> >>         function val($name, $value = null)
> >>         {
> >>                 static $values = array();
> >>
> >>                 if ($value === null) {
> >>                         return isset($values[$name]) ? $values[$name] :
> > null;
> >>                 } else {
> >>                         return $values[$name];
> >>                 }
> >>          }
> >>
> >> 2) Create a php script that searches out define("SOME_NAME_PATTERN",
> >> "value") and replaces that with val("some_name_pattern", "value").
> >>
> >> 3) Create a php script that searches out SOME_NAME_PATTERN and
> >> replaces with val("SOME_NAME_PATTERN");
> >>
> >> Not too bad in terms of work, as PHP's parsing capabilities are really
> > nice.
> >>
> >> Hope this gives you ideas :)
> >>
> >> Adam
> >>
> >
> > That's probably quite some work given the many defines.. Fact is, constants
> > are, as the name says, constant. Would it be possible to just not include
> > the general file?
> > Second, though not 100% sure if it works for E_STRICT is using @ before all
> > defines to silence the warning. You could do a simple replace for that..
> >
> > - Matijn
> 


I think the point is that the code is relying on overriding the
constants, so that wouldn't help at all. I think the best thing would be
to re-write the code, constants are never meant to be treated like that,
it's entirely the opposite of what a constant is.
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to