私のPHPアプリケーションにグローバル変数クラスを使用することには些細な問題があります。時間の経過と共にファイル名やフォルダ構造を変更することになるので、この変数の格納方法を本当に使いたいと思っています。PHP静的変数をクラス内の他の変数に使用
私は、変数であるpublic $root
をメソッドの中にない変数に使いたいと考えています。
:
public $root = "/rootfolder/";
public $something = $root . "path/";
しかし、私はこのエラーを取得しておいてください。
Fatal error: Constant expression contains invalid operations in C:_server\htdocs\p\chestools\core\php\global.php on line 26
ここに私の完全なページがあります:
class gvars {
public static $debug_mode = true;
/*
* Tab Title Control
* n\a
*/
public static $tab_after = " | Chestools";
public static $tab_name_enable = true;
/*
* Dialouge Control
* utils.dialouges.php
*/
public static $dia_show_fatal = true;
public static $dia_enabled = true;
/*
* Page Paths
* n\a
*/
public static $root = "/p/chestools/";
public static $path_home = "Home";
public static $path_contactus = "Contactus";
public static $path_login = "Login";
public static $path_signup = "Signup";
//General Pages
public static $path_help = "Help";
public static $path_profile = "Profile";
//Student Pages
public static $path_select_cat = "Catagorys";
//Teacher Pages
public static $path_view_student = "View";
public static $path_create = "Create";
//Catagorys
public static $path_cat_math = "c/math/";
public static $path_cat_life_sci = "c/life-science/";
public static $path_cat_int_sci = "c/interactive-science/";
public static $path_cat_earth_sci = "c/earth-science/";
//Security
public static $path_sec_finish = "security/Finish";
public static $path_sec_change_password = "security/ChangePassword";
public static $path_sec_change_email = "security/ChangeEmail";
public static $path_sec_checkpoint = "security/Checkpoint";
/*
* System Paths
* n\a
*/
public static $head_css = "core/css/chestools.css";
public static $head_js_app = "core/js/app.js";
/*
* Footer Resource Paths
* n\a
*/
public static $path_dwa = "about/district-wide-accounts/";
public static $path_isa = "about/independent-school- accounts/";
public static $path_support = "support/";
public static $path_pp = "Privacy";
public static $path_tos = "Terms";
}
[5.0.0 - 5.6.26、hhvm-3.10.0 - 3.14.4,7.0.0-7.1.0RC3]で再生できません(https://3v4l.org/88Lot#v500) – Gordon