I use framework Kohana and I need to set global static variable which could be seen in every place of the code. Where may I declare it and in what way? (I think it do in bootstrap.php)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I found that the best way to declare global variables is to create config file File_name.php(your own name instead of File_name) in the application/config folder, declare variables there and so we can access them in the any controller by calling Kohana::config (‘File_name.Variable_name’);
The code in my config file is following:
And don’t forget to attach your config file in bootstrap.php by Kohana::$config->attach(new Kohana_Config_File(‘File_name’));