Okay so i’m reading a bunch of articles about trying to pass objects from page to page, which in some cases would help me out a great deal. However, the issue i’m having is that it’s not working for me.
I have created three simple classes to try to get something working so i know the steps to follow however it’s not working.
Is it even possible to do?
Here is the sample code i’m working with :
PHP Class:
[CODE]
<?php
Class testClass{
var $mName;
function testClass(){
}
function getName(){
return $mName;
}
function setName($inName){
$mName = $name;
}
}
starting HTML page:
[CODE]
<?php
include(‘./testClass.php’);
session_start();
?>
<html>
<head></head>
<body>
<?php
$myNmae = “testing123″;
$myClass = new testClass();
$myClass->setName($myName);
$_SESSION[‘testClass’] = $myClass;
?>
<p><a href=”to.html”>go to the other page</a></p>
</body>
</html>
The Final page:
[CODE]
<?php
include(‘./testClass.php’);
session_start();
?>
<html>
<head></head>
<body>
<p>
<?php
$testing = $_SESSION[‘testClass’];
$name = $testing->getName();
echo ‘<br /> The name is: ‘. $name . ‘<br />’;
?></p>
</body>
</html>
The outcome from the to.html page is just “The name is: ” and $name appears to be empty. But no errors are thrown or anything.
Help?