...

View Full Version : Include W/o Echoes



Xibe
07-28-2007, 09:28 PM
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?

JordanW
07-28-2007, 09:32 PM
Use sessions:

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

Page1.php


<?PHP
session_start();
$_SESSION['MySession'] = "This is a load of stuff that my first page has created";
?>


Page2.php


<?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:


unset($_SESSION['MySession']);


Will erase the session variable when needed!



~Jordan

Xibe
07-28-2007, 09:36 PM
Ahh, okay.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum