php全局变量与'sourced'php文件

I have my web site in html, with php chunks embedded. I define some variables in the main page as

<?php
$GLOBALS['myVar']= "something";
?>

later I have

<?php
echo '<p align="center"><img src="./tempImg.php">';
?>

the tempImg php file displays, using the phplot.php lib, a dynamic plot of some data read from the database and in the tempImg.php file I must use the myVar variable. I tried using the GLOBALS[], the _SESSION[] but I am not able to share the variable in this way.

thanks for any help

$GLOBALS['myVar']= "something";
echo '<p align="center"><img src="./tempImg.php?myVar=' . $GLOBALS['myVar'] . '">';

Or just:

$myVar = "something";
echo '<p align="center"><img src="./tempImg.php?myVar=' . $myVar . '">';

Then access $_GET['myVar'] in tempImg.php.