Upgrade to PHP5 has killed my site

Please help!!!

bridalnet.com.au now comes up with:
Fatal error: Cannot re-assign $this in /home/guardian/BNnonpublic_php/Hiddens.Class.PHP on line 27
since the upgrade to PHP5.

I have found some references to assigning $this to null and a workaround, but my code is different:
Generate some hiddens fields from input array. Name gets from array key, value urlencoded.
class Hiddens
var $_Data;

$input Array with data from what all will be generated
function Hiddens($input)
	foreach ($input as $name => $value) { ?>
		<? if (!is_array($value)) { ?>
			<input type="hidden" name="<?=$name?>" value="<?=urlencode($value)?>">
		<? } else { ?>
			<? foreach ($value as $key => $sub_value) { ?>
				<input type="hidden" name="<?=$name?>[<?=$key?>]" value="<?=urlencode($sub_value)?>">
			<? } ?>
		<? } ?>
	<? }
	$this = ob_get_contents(); ob_end_clean();


I didn’t write this stuff and have little to no idea what it does.

Can someone please help?

I am not really an “expert” in OOP per say… but I would have thought you would use:

$this->someVar = obgetcontent etc… and simply not $this = …

because to me $this points to an instance of a variable which is already created so to me what you seem to be doing is:

$instance = new class(); //instance already created
$this = ob_get_contents() //re-creating/defining an instance?

Like i said I am not an expert so take this with a grain of salt lol… sorry if i couldnt help u more!

another thing I would try is:

instead of $this = ob_get_contents(); ob_end_clean();

i would just do ob_get_contents(); ob_end_clean();

What this function does in PHP 4 is the following:

It takes the input, whether a single value or an array, and creates a number of hidden input fields in an HTML form. When you instantiate the Hiddens object, the function tries to change $this (which refers to the object itself) to the string of hidden input fields.

The ob_ functions are being used to buffer the output and allow you to stick it into a variable instead of immediately outputting it to the screen.

Try this:

Change this line:

$this = ob_get_contents(); ob_end_clean();

To this:

$contents = ob_get_contents(); ob_end_clean();
return $contents;

This will work if you use the Hiddens object by assigning it to some variable like this:

$hidden_fields = Hiddens($array);

Where $array is the array of values being passed to the object.

I eventually tracked down the original developer and he was able to do some jiggery pokery and got it to work.

Thanks anyway gdutreix