Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    get variable from included file

    Hi,

    I have a master file in which I have included two external files. I tried to echo a variable in the 1st included file, which is defined in the second included file but it didn't work?

    PHP Code:

    // File that tries to get the variable
    <?php include("1st_file.php"); ?>

    // File that defines the variable
    <?php include("2nd_file.php"); ?>
    How can I get a variable that is created in 2nd_file.php to 1st_file.php ?

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    You cannot access a variable that does not yet exist.


  •  

    Posting Permissions

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