views:

64

answers:

1

i have this http://pastie.org/836744 script, which works outside the class completely fine, but it does not work inside another class, i have added the global vars in method too, which are being used inside other functions, but that didnt work.

following is demo code

include_once("prayer_calculation.inc.php");
$prayers =  get_prayer_times(67.0181732, 30.2094593, 5, 3, 22, 2, 2010, 0, 1678, 1010, 10);

echo $prayers['0']->hour.' '.(($prayers['0']->hour <= 12) ? $prayers['0']->hour : ($prayers['0']->hour - 12)).':'.sprintf("%02d", $prayers['0']->minute).' '.(($prayers['0']->hour < 12) ? 'am' : 'pm');
echo '<br>';
echo (($prayers['1']->hour <= 12) ? $prayers['1']->hour : ($prayers['1']->hour - 12)).':'.sprintf("%02d", $prayers['1']->minute).' '.(($prayers['1']->hour < 12) ? 'am' : 'pm');
echo '<br>';
echo (($prayers['2']->hour <= 12) ? $prayers['2']->hour : ($prayers['2']->hour - 12)).':'.sprintf("%02d", $prayers['2']->minute).' '.(($prayers['2']->hour < 12) ? 'am' : 'pm');
echo '<br>';
echo (($prayers['3']->hour <= 12) ? $prayers['3']->hour : ($prayers['3']->hour - 12)).':'.sprintf("%02d", $prayers['3']->minute).' '.(($prayers['3']->hour < 12) ? 'am' : 'pm');
echo '<br>';
echo (($prayers['4']->hour <= 12) ? $prayers['4']->hour : ($prayers['4']->hour - 12)).':'.sprintf("%02d", $prayers['4']->minute).' '.(($prayers['4']->hour < 12) ? 'am' : 'pm');
echo '<br>';
echo (($prayers['5']->hour <= 12) ? $prayers['5']->hour : ($prayers['5']->hour - 12)).':'.sprintf("%02d", $prayers['5']->minute).' '.(($prayers['5']->hour < 12) ? 'am' : 'pm');
+1  A: 

Looks like a scope problem. The various arrays in the script will only have local scope to the point where you include the file, so using global to try and reach them inside the functions won't work.

Try setting the fixed arrays up as globals, e.g. $GLOBALS['L1'] then you should be able to reach them inside the functions.

Mike
hmm ok will give a try.
Basit