Trying to understand what is namespaces, and what is point of using them, and where to use them, and how to use them..
Code:
<?php
namespace foo;
class Cat {
static function says() {echo 'meoow';}
}
namespace bar;
class Dog {
static function says() {echo 'ruff';}
}
namespace animate;
class Animal {
static function breathes() {echo 'air';}
}
use foo as feline;
use bar as canine;
use animate;
echo \feline\Cat::says(), "<br />\n";
echo \canine\Dog::says(), "<br />\n";
echo \animate\Animal::breathes(), "<br />\n";
?>
Getting error:
Fatal error: Uncaught Error: Class 'feline\Cat' not found in C:\Users\bird\
\n";` loose the first backslash – RiggsFolly Mar 11 '20 at 11:44