English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I've tried adding variables to the $_SERVER variable, to no avail. It accepts an assignment just fine, but doesn't recognise the key on the following page.

I know web servers are stateless, but there are mechanisms in other languages that perform this kind of function (the SERVER variable in ASP, for example, if I remember correctly) so I'm hoping I just missed something in the manual.

test01.php:
-----------
$_SERVER["myobject"]="steve";
?>

test02.php:
-----------
echo $_SERVER["myobject"];
?>

2007-02-19 07:31:38 · 1 answers · asked by dead_elves 3 in Computers & Internet Programming & Design

Basically I want to build a men structure dynamically from a directory+subdirectory listing. Since it'll be the same for every page, I was hoping to save some server overhead by only doing it once.

I don't think the session variable would work, because I'm already using that to track users from page to page. At best I could give each user his own menu object, but that would not save much on processing, since the site is built around a single ajax-type interface page. Additionally, I think the memory overheads of keeping the page structure stored separately for each user makes this unfeasable.

Normally I'd implement this as a servlet project, but customer requirements prevent that in this instance.

2007-02-19 20:30:51 · update #1

1 answers

You can. Just look at following simple code and read at link below.
//class.test.php
class test
{
function test()
{
echo "Object created";
}

function testfunc()
{
echo "in test func";
}
}
?>
------------------------------------------------
//test.php
require_once "class.test.php";
session_start();
$objTest = new test();
$_SESSION['objTest'] = $objTest;
echo "

";
print_r($objTest);
echo "
";
?>
Test1
---------------------------------------------------------
//test1.php
require_once "class.test.php";
session_start();
$objTest = $_SESSION['objTest'];
echo "
";
print_r($objTest);
echo "
";
$objTest->testfunc();
?>
--------------------------------------------------

Read at this link
http://lists.evolt.org/archive/Week-of-Mon-20031027/150721.html

2007-02-19 20:01:25 · answer #1 · answered by Atif Majid 3 · 0 0

fedest.com, questions and answers