I work a lot in PHP but I never really understand the namespace method in PHP. Can somebody help me here? I have read on php.net’s website its not explained good enough, and I can’t find examples on it.
I need to know how I can make code in sample version.
- namespace: sample
- class: sample_class_1
- function: test_func_1
- class: sample_class_2
- function: test_func_2
- function: test_func_3
- class: sample_class_1
Like this?
If you’re in another file you don’t need to call
namespace {to enter the root namespace. So imagine the code below is another file “ns2.php” while the original code was in “ns1.php”: