Passing data between scripts

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mpm3@yahoo.com

    #1

    Passing data between scripts

    I have a php script which displays some HTML stuff along with some
    images generated on the fly by another php script. Example:

    <?php

    // Script1.php

    $fp = fopen("c:/some_path/file1.txt", "r");
    $tmp = explode(" ", fgets($fp));
    fclose($fp);

    $ts1 = $tmp[1];
    $ts2 = ltrim (date("h:iA", strtotime("$ts1 +30 minutes")), 0);
    $date = date("D M d, ") ."$ts1 - $ts2.";

    echo "<ul><h1 align=\"left\"> ABC Company.</h1>";
    echo "<h2 align=\"left\"> $date</h2></ul>";
    echo "<img src=\"Script2.p hp\" border=0 width=500
    height=500><br> ;\n";
    echo "<br>";

    ?>

    Is there any way that I can have Script2.php access to the array $tmp
    without having it (Script2.php) open file1.txt and reading in the data?
    It's a large data file, not something I can pass as variables in the
    URL. Ex:
    echo "<img src=\"Script2.p hp?var1=$tmp[1]&var2=$tmp[2]\" border=0
    width=500 height=500><br> ;\n";


    Thanks

    MPM

  • Daniel Tryba

    #2
    Re: Passing data between scripts

    mpm3@yahoo.com <mpm_three@yaho o.com> wrote:[color=blue]
    > <?php
    > // Script1.php[/color]
    [do stuff][color=blue]
    > echo "<ul><h1 align=\"left\"> ABC Company.</h1>";
    > echo "<h2 align=\"left\"> $date</h2></ul>";
    > echo "<img src=\"Script2.p hp\" border=0 width=500
    > height=500><br> ;\n";
    > echo "<br>";
    > ?>
    >
    > Is there any way that I can have Script2.php access to the array $tmp
    > without having it (Script2.php) open file1.txt and reading in the data?[/color]

    You could use a session, the net effect is that the data is written to
    another file and script2 reads that file, see the manual at
    http://nl2.php.net/manual/en/ref.session.php for more info.

    Comment

    Working...