Hi All.
For some odd reason it feels like this should be an extremely easy principle but yet I cannot seem to do this properly.
I know that there might be other ways to accomplish this but for the sake of my current project, i require this.
What i need is to call a method within a class that belongs to the global namespace from within a class that belongs to a defined namespace.
<?php
$myNsClass = 'myNamespace\someClass';
echo $myNsClass::printHello("John");
class myClass {
function sayHello($name) {
return 'Hello ' . $name;
}
}
namespace myNamespace {
class someClass {
function printHello($name) {
// call sayHello in myClass
$classsss = new myClass();
return $classsss->sayHello($name);
}
}
}
?>