I got 2 PHP files:
courier.php
<?php
namespace Shipping;
class Courier
{
public $name;
public $home_country;
public function __construct($name) {
$this->name = $name;
return true;
}
public function ship($parcel) {
// sends the parcel to its destination
return true;
}
public static function getCouriersByCountry($country) {
// get a list of couriers with their home_country = $country
// create a Courier object for each result
// return an array of the results
return $courier_list;
}
}
?>
filephp.php
<?php
//namespace Fred;
require 'courier.php';
//function __autoload($classname) {
// include //strtolower($classname).'.php';
//}
$mono = new Shipping\Courier('Monospace Delivery');
//var_dump($mono);
// accessing a property
echo "Courier Name: " . $mono->name;
// calling a method
$mono->ship($parcel);
$spanish_couriers = Courier::getCouriersByCountry('Spain');
echo $spanish_couriers;
?>
But when I execute filephp.php I get this error:
Fatal error: Class 'Courier' not found in D:\masterphp\test.php on line 19
line 19 is this:
$spanish_couriers = Courier::getCouriersByCountry('Spain');
What is wrong with my scope resolution?