本文介绍了在laravel PHP中访问名称空间之外的静态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在名称空间App\Http\Lib中有一个php类作为GISApplication包含静态数据成员。我想设置&访问来自命名空间之外的不同类的静态数据成员的值。我怎样才能设置&访问该值。



Hi All,
I had one php class in namespace App\Http\Lib as GISApplication which contains static data members. I want to set & access values of that static data members from different classes outside of namespace. How Can I set & access that values.

<?php
namespace App\Http\Lib; 

class GISApplication
{
public static $LOGINUSER_TYPE;
public static $USERMODULE;

// More Static Data Members

}





假设我想要从App\Http\Controllers命名空间&中的LoginController类设置这些成员的值。从App\Http\Operations命名空间中的不同类访问该值。



请建议。



我尝试过:



我从App\Http\Controllers命名空间中的LoginController类设置值AS



Suppose I want to set values of these members from LoginController class in App\Http\Controllers namespace & access that values from different classes in App\Http\Operations namespace.

Please suggest.

What I have tried:

I set values from LoginController class in App\Http\Controllers namespace AS

GISApplication::$LOGINUSER_TYPE = $auth->type;
GISApplication::$USERMODULE = $auth->module;





当我从App中的FrontOperation类访问值时\\ Http\Operations AS



When I access values from FrontOperation class in App\Http\Operations AS

GISApplication::$LOGINUSER_TYPE



我将获得空白值。


I will getting blank value.

推荐答案






假设我想要从App\Http\Controllers命名空间&中的LoginController类设置这些成员的值。从App\Http\Operations命名空间中的不同类访问该值。



请建议。



我尝试过:



我在App\Http\Controllers命名空间中设置LoginController类的值AS



Suppose I want to set values of these members from LoginController class in App\Http\Controllers namespace & access that values from different classes in App\Http\Operations namespace.

Please suggest.

What I have tried:

I set values from LoginController class in App\Http\Controllers namespace AS

GISApplication::



这篇关于在laravel PHP中访问名称空间之外的静态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 17:58