41 users online (1 members and 40 guests)  


  Results 1 to 6 of 6

Related

  1. Replies: 0
  2. Yop Scripts - Free Cool Scripts To Use..    Forum: Internet Services
    Replies: 1
  3. convert a perl variable to javascript variable    Forum: Javascript Forum
    Replies: 0
  4. Replies: 3
  5. Replies: 5
  1. #1
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Pass variable between php scripts.

    This is probably a school boy question, but I need to know how to pass a variable between two scripts. This is kinda what I want to do:

    Code:
    <?php
    $title = 'Index';
    require('header.inc');
    ...
    ?>
    header.inc would have something like this:

    Code:
    <DOCTYPE PUBLIC HTML ...>
    <head>
    <title>$title</title>
    </head>
    ...
    I've just started playing with php and find that it is so much simpler and quicker than perl for db connections.

    TIA

    u

  2. #2
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Pass variable between php scripts.

    Something like
    Code:
    <DOCTYPE PUBLIC HTML ...>
    <head>
    <title><?php echo $GLOBALS['title']; ?></title>
    </head>
    ...
    might do the trick ...

  3. #3
    uthus's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Ft Hood
    Posts
    75

    Re: Pass variable between php scripts.

    Quote Originally Posted by DeadMeatGF
    Something like
    Code:
    <DOCTYPE PUBLIC HTML ...>
    <head>
    <title><?php echo $GLOBALS['title']; ?></title>
    </head>
    ...
    might do the trick ...
    That did it. Thanks.

    u

  4. #4
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: Pass variable between php scripts.

    Excellent.
    Glad to be of help

  5. #5
    loanskey's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2006
    Posts
    11

    Re: Pass variable between php scripts.

    the better solution is with the session

    you can passthe varibales from one page to another by sessions


    Ravish Kumar
    Last edited by HTML; 04-07-2006 at 06:09 AM.

  6. #6
    roders's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2006
    Posts
    3

    Re: Pass variable between php scripts.

    No need to use session here. what DeadMeatGF wrote is correct.



Tags for this Thread