Thread: Modular PHP

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    2
    Rep Power
    0
    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:

    ***main script***
    [snip]
    require "util.inc" // contains print_debug()
    require "scoreboard.inc" // contains get_scoreboard()

    From within get_scoreboard(), I cannot print_debug.

    Any ideas? Thanks.

    --Brant

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    Hi Brant,

    Did you already try the include() function instead of require?

    Peter

    [This message has been edited by PAV (edited January 24, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    2
    Rep Power
    0
    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.

    --Brant

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo