SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variables in different files...

    Hmm... I earlier wanted to make it so that you could use the same variables in 2+ different files!

    I never got a working answear, but I'm here with an idea that I want you to see if it will work!

    If I add this at the top of my files, and I have a variables in it, can I just use the variables regularly?

    Add this:

    PHP Code:
    <?php
    include("var.php");
    ?>
    Will that work?

    Hope so!

    Thanks,
    ~someonewhois

  2. #2
    SitePoint Enthusiast Crooner's Avatar
    Join Date
    Apr 2001
    Location
    Chambersburg, PA
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you include a file with variables defined it will work just as if you had defined the variables inside the file itself.

    Of course, any variables you want to use inside a function you will need to define as global inside that function.

    Before you get too deep into application development you'll want to learn classes and sessions also. It will end up simplifying your life
    Dean-Martin.com Managed IT Solutions
    eLiveHost.com Premium Hosting
    4StateShopper.com Community Forums

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I read the thing at php.net... I get it now!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •