What is the role of define in addition to defining constants? Can I change the definition of a constant? Why have the APP been defined so many times? The constant value seems to be a path. Shouldn't it be a defined constant?
Define ("APP", "./admin"); what is the role of this sentence?
Reply to discussion (solution)
Define defines constants. constants can be numbers or strings .. When you echo the APP;, the output is./admin. Similar to defining variables
After a constant is set, its value cannot be changed. Define ("APP", "./admin");, not a constant, defines the compilation Directory, that is, the app scope is under admin.
A constant is the identifier (name) of a single value ). This value cannot be changed in the script.
Define is to define constants. any content can be used as long as the values comply with the syntax rules.
Define ("APP", "./admin"); defines a constant APP whose value is./admin.
To use an APP, use./admin.
Similar definitions are available in multiple files because your files are not executed simultaneously (during an HTTP session ).
When index. php is executed, the APP is./home.
When admin. php is executed, the APP is./admin.
When wap. php is executed, the APP is./wap
In this way, you don't have to differentiate the directory in which the program actually works.
A common usage is to restrict files to access from a certain file (such as a bootstrap file). This common mode is:
If (! Defined ("XXXX") exit;
That's how it works. nothing else.
Defined and define are different methods.