Welcome Guest, Not a member yet? Register   Sign In
different behaviour when "passing on libraries" in apache/php5 and iis/php4
#1

[eluser]bAum[/eluser]
Dear all,

I currently experiencing a strange problem. I'm developing a site on my pc, running apache with php5. The thing is deployed on a web server running IIS with php4. The problem is the following: I wrote a library that among other things tracks some general information such as the language that is being used. This information is set in the controller as this:

$this->reader->setLanguage($lang);

When I want to use this information later on in a view, i'll have a method

$this->reader->getLanguage($lang);

Here it comes: while things work fine on the php5 host, on the php4 host the getLanguage call returns an empty string (the default value). After investigating this problem it turns out that in the php5 case the libraries are correctly "passed-on" to the views, whereas in the php4 case the libraries are newly instantiated...

Has anyone come across this problem, any ideas how to fix it?

Best regards,

bAum
#2

[eluser]bAum[/eluser]
A fix for this problem is the following code snippet which I added on top of each view file.

Code:
if ( version_compare( phpversion(), '5', '<' ) ) {
        $myCI =& get_instance();
        $this->reader =& $myCI->reader;
        $this->auth =& $myCI->auth;
    }

This way, I make sure that the local references in the view actually reference the library objects of the CI object. It's quite silly though, so any help is very much appreciated.




Theme © iAndrew 2016 - Forum software by © MyBB