Something really weird happening...PHP 5.....
I include a file at the top of a script, the included file defines some constants.
Then later on in the script, I include another file that has some lines that echo the values of those defined constants. Thing is, the included file doesn't have access to those constants.....
I proved it by using get_defined_constants from within the included code...and the constants array does NOT contain a USER array.
As I understand it, included files should have access to vars of all scopes that have been defined in the original script up to that point.
What gives? Anyone?
Constants and includes
Moderator: General Moderators
it seems that the statement
" When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward."
in the PHP manual for the include function means variables, not user defined constants. in order for that to work the constants have to be defined for the included file as well.
or at least, that's how I got it to work.
" When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward."
in the PHP manual for the include function means variables, not user defined constants. in order for that to work the constants have to be defined for the included file as well.
or at least, that's how I got it to work.