PHP 5 -> PHP 4... help, please!

Miscellaneous Forums/General Discussion/PHP 5 -> PHP 4... help, please!

Argh...

A web host (Canaca) seems to be living in the stone ages, as yet unable to carry out a simple (not to mention FREE!) upgrade from PHP 4 to PHP 5.

As a result, I have had to severely mangle a little web site to get it talking to PHP 4. (Well, not much so far; I first had to remove a few hard-coded paths that I had).

Not much mangling had occurred before I encountered an error. (One that makes me wonder how anyone can possibly consider PHP 4 a viable alternative to the vastly superior version 5).

Without further adieu:
I get the following error message with my page:
Fatal error: Only variables can be passed by reference in /var/www/html/test/dhsfuncts.php on line 34


Here is the very messy (and rather idiotic) Page class, used to unify every aspect of page generation into a single concept (which turns out to be, surprisingly, a heck of a lot more sane than various other CMS systems out there):
	class Page
	{
		var $Path; //Public in PHP 5
		var $data=array(); //Private in PHP 5
		
		function Page($Path)
		{			
			$this->Path=$Path;
			
			if( file_exists($Path.'/data.vars') )
			{
				$varsList=str_replace(array("\n","\r"),'',file_get_contents($Path.'/data.vars'));
				$datatest=array();
				parse_str($varsList,$this->data); //Stuck here... PHP 4 doesn't like the way I'm passing a var of an object by reference
				//parse_str($varsList,$datatest);
				echo('Testing...'.$this->Title);
			}
		}
		
		function Output($mode='cnt',$Summarize=0,$DispLength=-1,$LinkTo=0,$BackLink=1)
		{
			//Snip
		}
		
		function Summarize($length)
		{
			//Snap
		}
		
		function GetContents($length = -1)
		{
			//("Blasted right handed scissors!")
		}
		
		function __get($key)
		{
			if (isset($this->data[$key])) {
				return stripslashes($this->data[$key]);
			//} elseif( isset($this->$key) ) {
			//	return $this->$key;
			} elseif( isset($GLOBALS['def_varsList'][$key]) ) {
				return $GLOBALS['def_varsList'][$key];
			}
		}

		function __set($key, $val)
		{
			if (isset($this->data[$key])) {
				$this->data[$key] = $val;
			//} elseif( isset($this->$key) ) {
			//	$this->$key=$val;
			}
		}
	}
	
	overload('Page'); //Set overloading for __get and __set. PHP 4 only. Comment out for PHP 5


This worked in PHP 5. The problem here has something to do with parse_str($varsList,$this->data).
More specifically, I believe it has to do with my passing $this->data by reference.

The commented out parse_str($varsList,$datatest) does work. The only difference I can think of between that and the code that I want (which gives a fatal error) is that $datatest is a variable local to the function instead of the class, and maybe that it was defined as an array in the same place.

Possible reasons that I can think of:

-PHP 4's function overloading being ugly. (Thus __get and __set could be behaving very differently in PHP 5...)

-Maybe PHP 4 doesn't like to pass arrays by reference? (That would be weird)

-Maybe PHP 4 doesn't like to pass variables in an object by refference?


As is obvious, I am stumped.
Any thoughts?
Thanks in advance!

Try setting that to a variable rather than passing in the refference.

See if that corrects it.

as yet unable to carry out a simple (not to mention FREE!) upgrade from PHP 4 to PHP 5.


Actually, there are known issues with using Apache2 and Php5. There are workarounds, but messy.

Have you tried passing a pointer?

parse_str($varsList,&$this);

function parse_str($varsList, &$object)
{
     $data = $object->data;
}