I have this code on one part of an html page
<?php
$file = 'events.xml';
$xml = simplexml_load_file($file);
function popCal(){
echo $xml->day->event[0]->name;
}
echo $xml->day->event[0]->name;
$day=array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7);
?>
and this code in a table cell somewhere else in same page
<?php popCal(); ?>
If I put a simple statement like echo “Foo”; in popCal function it works. If I put echo $xml->day->event[0]->name; outside the function, it works. Is there any obvious reason why this shouldn’t work inside the function popCal()?