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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    66
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Include W/o Echoes

    In a certain script I have, I would like to call out the variable from another script, but if I use the include function, it displays that whole page of stuff. Is there anyway to call a variable from another .php without include or require?

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    159
    Thanks
    2
    Thanked 15 Times in 15 Posts
    Use sessions:

    http://uk3.php.net/manual/en/ref.session.php


    Page1.php
    PHP Code:
    <?PHP
    session_start
    ();
    $_SESSION['MySession'] = "This is a load of stuff that my first page has created";
    ?>
    Page2.php
    PHP Code:
    <?PHP
    session_start
    ();
    echo 
    $_SESSION['MySession'];
    //This shows "This is a load of stuff that my first page has created" on the screen.
    ?>

    NOTE: You must start both pages with session_start(); and it has to be the FIRST thing on the page.


    The code:
    PHP Code:
    unset($_SESSION['MySession']); 
    Will erase the session variable when needed!



    ~Jordan

  • #3
    New Coder
    Join Date
    Nov 2005
    Posts
    66
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Ahh, okay.


  •  

    Posting Permissions

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