I try to initialize an array using another array in php class. Here is the code:
<?php class test
{
var $nodeDomain = array
("gd88" =>"10.10.104.88", "gd02" =>"10.10.104.2");
var $node = array
("x86-mysql" =>$nodeDomain['gd88'],
"x86-hbase" =>$nodeDomain['gd02']);
function show ()
{
print_r($node);
}
}
?>
I got this error: Parse error: syntax error, unexpected T_VARIABLE in /root/workspace/php/array.php on line 6
But when I run the code without using class it works fine. I mean I run the following code:
var $nodeDomain = array
("gd88" =>"10.10.104.88", "gd02" =>"10.10.104.2");
var $node = array
("x86-mysql" =>$nodeDomain['gd88'],
"x86-hbase" =>$nodeDomain['gd02']);
I am not quite clear about the difference of php class and php script. Can anyone explain this?
Thanks.