Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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??
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?
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 :)
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.
Ok cool, well it seems to be working ok, so I will stick with the direct alteration :).