I'm trying to make changes to an object via a user-defined function but it doesn't appear to update the object.
I have my main code which creates a pdf object (using ezpdf etc). I am writing generic graphing functions to include in my pdf. Therefore I want to build a library /lib/graph_functions.php to be used in the main script via a 'require'. Here is a snippet of the main script:
require ('../lib/graph_functions.php');
$pdf =& new Cezpdf();
$all = $pdf->openObject();
$pdf->saveState();
build_graph_type1($pdf);
My function snippet is:
function build_graph_type1 ($pdf) {
$pdf->addText(10, 10,12,"Hello");
}
The pdf works fine but anything I do to the pdf in the function build_graph_type1() doesn't appear to have an effect on the original pdf object. What I want to do is pass the pdf variable as a reference to the original object and then make changes to it in my function. Is this possible? Am I making a copy of the object by mistake? Do I need to assign a reference to a new variable?
Any help would be great....