php - Calling static class outside of namespace
Inside a class "cl1" in the namespace "space1", there is the function "fctn1", and inside it I want to call the static method "fctn2" from the class "cl2". The class cl2 is not inside any namespaces.
<?php
namespace space1;
class cl1
{
public function fctn1()
{
cl2::fctn2();
}
}
<?php
class cl2
{
public static function fctn2()
{
// stuff here
}
}
How can I call fctn2 inside the fctn1 on PHP?
I tryied simply calling the method inside the class just like shown in the code on the question.
Answer
Solution:
Honk der Hase gave a satisfactory answer in a comment:
SourcePrepend a backslash to address the global namespace:
\cl2::fetch2();