22999 Posts in 11854 Topics by 2828 members
|Go to End|
1 October 2009 at 11:56pm
I have tried on several occasions now to use Object::set_static() to change the Static variable of an object, but it never seems to do anything.
The best example I can give is while I am trying to change the $url_segment in CMSMain. I use this:
Object::set_static('CMSMain', 'url_segment', 'cms');
But it seems to make no difference, if I manually change the variable however, it does what I want to.
Anyone know whats going on? I do the call in my _config.php file??
2 October 2009 at 12:45am
Any particular reason why you want to use Object::set_static instead of simply CMSMain::$url_segment = <value>. What's the advantage of the Object::set_static approach?
2 October 2009 at 1:37am
I have done that, I was just thinking Object::set_static() must be preferred to just directly setting the variable, otherwise I wasn't sure why it would exist...
Maybe I am thinking too much
2 October 2009 at 1:41am
I think the set_static method helps in cases where decorator or "extensions" are being used. So that you can set a static variable that doesn't really belong to the object itself, but to an extension of that object. I'm not really sure though ;)
But there's nothing wrong with setting the static variable directly. It surely is the better option from a performance point of view.
2 October 2009 at 1:57am
Ok cool, well it seems to be working ok, so I will stick with the direct alteration .
|Go to Top|