View Single Post
Old 12-01-2007, 01:55 AM   #10 (permalink)
MartynMJ
The Wanderer
Newcomer 
 
Join Date: Nov 2007
Posts: 14
Thanks: 1
MartynMJ is on a distinguished road
Default

Quote:
Originally Posted by bluesaga View Post
Pre-PHP 5 when you refer to a class in a function call, without using the ampersand operator then PHP would clone the class and not simply pass a reference as you are hoping for.

your code:
PHP Code:
<?php
require_once ( "class1.php" );
require_once ( 
"class2.php" );

$class1 = new class1;
$class2 = new class2 $class1 );

$class2->blah();

echo 
$class1->execute();

?>
Should be:
PHP Code:
$class2 = new class2 ( &$class1 ); 
First of all PHP Version 4.4.7.

And i tried adding the ampersand but still got the same outcome. As this needs to be done soon i have worked around it by returning the data and then calling to the template functions but this was quite a pain :p

Thanks all
MartynMJ is offline  
Reply With Quote