Good day to all.
---------------------INTRODUCTION---------------------
I work with the site engine in php. My study of php began with it. There were no problems, wrote new modules for the site and everything worked. Everything was fine until a few days ago I decided to figure out how the engine works, and how to write a full-fledged site engine from scratch. He began to understand a little and everything seems to be working. But I came across barrier number one.
---------------------PROBLEM---------------------
The problem is as follows. I have this code:
class ShowGeneralPage { public function show() { global $tpl_vars; ShowGeneralPage::tpl_vars_add(array( 'key_1' => 'value_1', 'key_2' => 'value_2' )); echo $tpl_vars; } function tpl_vars_add($display_vars) { global $tpl_vars; ...некий код... $tpl_vars = "некое значение"; } } I want to draw attention to the method of calling the function "tpl_vars_add" . I connect to the class from the index.php file. The ShowGeneralPage class is in a different file. When I connect to a class, I automatically call the "show" function. In the "show" function, using the "ShowGeneralPage::tpl_vars_add();" I call the function "tpl_vars_add" . And everything works fine. And if I just write "tpl_vars_add();" then nothing will happen. I call this function in the same class in which I am. How do I get the php handler to call my function by its name, and not by its path in the class? In the site engine, with which I worked this way it was implemented, and worked without any problems. I do not. I suspect that somewhere in that engine it was stated how to handle such moments correctly. What are your thoughts on this? Thank you in advance for your attention.
$this->tpl_vars_add()does not work. Checked. Why isglobalbad? On the contrary, it is very convenient if you need this variable to be available on all pages of the site. - intro94 2:42 pm"ShowGeneralPage::tpl_vars_add();", and I need to get a call to this variable through the construction"tpl_vars_add();", so as not to indicate the name of the class to which this function belongs, as it is inside the same class. - intro94