I will give a primitive example as I would like to:

сlass MyClass { //подключить file.php } //file.php содержит const MY_CONST = 'My Value'; //в итоге получить MyClass::MY_CONST; 

File.php itself can have a completely different name. Are there options for implementation?

  • Does this make sense? Count up your file changes and you have to go into the class code to correct the name. I would go the other way. Gee gee gee, create a class with your default values ​​and make> class MyClass extends MyDefault Although this is not ice, but still less hemorrhoids, if you really want to use variables from the file. :) - Artem
  • Gee count up the script will know that the file has changed from a certain dependency and will select the file considering this dependency! - Palmervan

1 answer 1

It should work, because they are superglobal. Only connect nada constants before using the class.

 PHP 5.3+ const MY_CONST = 'My Value'; PHP 5.2 define('MY_CONST', 'My Value'); 
  • I feel the catch is that the TS wrote the code and tried it out and failed. - Artem
  • file is connected before class use in topic - Maksym Prus
  • @Shrek TC wrote that it wants to get MyClass :: MY_CONST;))) If this is not possible, then of course it's easier to define and not take the point) - Palmervan