Hi, I've got a problem with a class, can you tell me what the problem is?
[a.php]
<?php
$g_a = "hello";
?>
[b.php]
require_once("a.php");
echo $g_a;
class Test
{
public static function GetA()
{
if ($g_a == null || $g_a == "")
throw new Exception("$g_a is an invalid value!");
return $g_a;
}
}
When loading b.php the echo correctly outputs "hello", but when i use Test::GetA() an exception gets thrown every time. Why can't my static functions in the class view the global variable?
Thanks
Skute
"There are 10 types of people in this World, those that understand binary, and those that don't!"
[a.php]
<?php
$g_a = "hello";
?>
[b.php]
require_once("a.php");
echo $g_a;
class Test
{
public static function GetA()
{
if ($g_a == null || $g_a == "")
throw new Exception("$g_a is an invalid value!");
return $g_a;
}
}
When loading b.php the echo correctly outputs "hello", but when i use Test::GetA() an exception gets thrown every time. Why can't my static functions in the class view the global variable?
Thanks
Skute
"There are 10 types of people in this World, those that understand binary, and those that don't!"