January 21st, 2000, 01:31 PM
I am trying to keep common functions in separate files and include/require them at the top of the current script. If I require two files in a script, calling a function from one file from the function in the other file does not work. Each function can be called successfully from the main script. For example:
require "util.inc" // contains print_debug()
require "scoreboard.inc" // contains get_scoreboard()
From within get_scoreboard(), I cannot print_debug.
Any ideas? Thanks.
Comments on this post
January 24th, 2000, 02:37 AM
Did you already try the include() function instead of require?
[This message has been edited by PAV (edited January 24, 2000).]
January 24th, 2000, 07:10 AM
I figured it out. It is a scope problem. In the scoreboard function, I have to add the line:
global $DEBUG; // the global var that tells if priniting should occur.
This defines the var and lets the func "see" the print_debug function located in the other file.
Now it prints.