Guys I want to declare my site name in config.php so I can access this variable from all files like add.php. Please let me know how to do this without global_variable on. By default global_variable is off and I want to do this keeping it off? GCS
You can declare ALL your variables in a 'my_vars.php' i.e. and then include this file into the rest of your files which require the variables : include ("path/to/file/my_vars.php"); PHP: or require 'path/to/file/my_vars.php'; PHP:
I would suggest using CONSTANTS whenever possible if the values won't change, as they have global scope regardless
define("CONSTANT", "Hello world."); the above command is for declaring...and assigning value to it and the below is used for printing.. echo CONSTANT; // outputs "Hello world."
Thanks a lot buddy. Is this variable in all script (different php files) automatically or I have to include this php file in all files like above? GCS
This may also useful. Declare ALL your variables in a 'my_vars.php' i.e. and then include this file into the rest of your files which require the variables : php Code: include ("path/to/file/my_vars.php"); or php Code: require 'path/to/file/my_vars.php';