PHP namespace example

  • 2020-03-31 21:32:27
  • OfStack


namespace bakbaba; 
function bab(){ 
echo "bi"; 
} 
namespace kkk; 
function k1(){ 
echo "k1"; 
} 
bakbababab();//Use another namespace under the KKK namespace, note the  in front
use bakbaba as b;//It is still in the KKK namespace, but the following method is correct when using an alias
#use bakbaba as b;//You may not use the  sign in front
bbab();//There should be no  sign before using the namespace under the alias
k1();//There is no error in calling this function, indicating that use does not affect the current namespace

Related articles: