--- whoisquilty <[EMAIL PROTECTED]> wrote:

> Thanks, James. What if I want to pass $out to another page? I tried that and
> since my $out has code in it, the page is reading it as code and not as a 
> variable in a link.
> 
> Jeremy

Most of the time PHP is used to generate custom HTML.  Some of that custom
content is determined by the logic of the program and some may come from a
database query or other resource.

If you are generating a block of content (text + HTML) you can best pass it
from one page to another using session variables.

The basic procedure in PHP is to start your opening PHP tag (<?php) start on
the first line on the first character position.  Then do a session_start(),
build up your $out variable, and save it in a session variable.

_____
<?php
session_start();
$out = "";
$out .= "first line<br />\n";
$out .= "second line<br />\n";
# ...
$_SESSION['html'] = $out;
?>

The underscores are not part of the file of course.  It's important that you do
not do any print or echo statements before you save the value in the $_SESSION
superglobal.

In your second page you do something similar:
_____
<?php
session_start();
$html = $_SESSION['html'];

print $html;
?>

James

Reply via email to