Forum Moderators: coopster
class maps{
//Initalize the city array
var $City = array();
$City['city1']['Dundas']['Codes'] = "L9H, L85"; //ERROR LINE
$City['city1']['Dundas']['Amount'] = 13915;
$City['city2']['North Burlington']['Codes'] = "L7M, L7P";
$City['city2']['North Burlington']['Amount'] = 19668;
$City['city3']['South Oakville']['Codes'] = "L6K, L6L, L6M";
$City['city3']['South Oakville']['Amount'] = 26044;
function display_cities(){
echo "hi";
foreach($this->City as $kCity=>$vCity){
echo $kCity." = ".$vCity."<br>";
}
echo "bye";
}
}
Error is in this class file on the line noted.
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION
This is probably really simple, but i've been looking at it for a couple hours and cant figure it out. Thanks,
Ryan
<?php
class maps{
//Initalize the city array
var $City = array();
function maps()
{
$this->City['city1']['Dundas']['Codes'] = "L9H, L85"; //ERROR LINE
$this->City['city1']['Dundas']['Amount'] = 13915;
$this->City['city2']['North Burlington']['Codes'] = "L7M, L7P";
$this->City['city2']['North Burlington']['Amount'] = 19668;
$this->City['city3']['South Oakville']['Codes'] = "L6K, L6L, L6M";
$this->City['city3']['South Oakville']['Amount'] = 26044;
$this->display_cities(); // execute this class method
}
function display_cities()
{
echo "hi";
foreach($this->City as $kCity=>$vCity){
echo $kCity." = ".$vCity."<br>";
}
echo "bye";
}
}
$map = new maps();
exit;
?>