Strange Behaviour when working with Class Variables
Posted: Sun May 11, 2003 12:28 am
Hey guys and gals,
I've got a problem that I've been working on for a few hours with no solution thusfar. I'll try to explain below.
I have a file, lets say vars.php. Inside that is code like the follows:Now, I have another file, called say loadVars.php. Although these names may seem abstract here, they fit in with a much larger project. Inside this file is a class, the code is something like this:I have a third file, say called outputData.php. The code looks like this...Now, in the main file, the code looks like this...The problem is, sometimes the code outputs the correct info (it should output 120), but sometimes it outputs nothing, it changes. This is a really odd behaviour, something that is extremely strange, ive never seen the result change when you run it back to back times and get different results, really odd.
If anyone has any suggestions, I would greatly appreciate it.
Regards,
Shawn
I've got a problem that I've been working on for a few hours with no solution thusfar. I'll try to explain below.
I have a file, lets say vars.php. Inside that is code like the follows:
Code: Select all
//vars.php
$tmp = 120;
$tmp2 = 160;Code: Select all
//loadVars.php
class loadVars {
var $tmpVar;
function loadVars() {
include 'vars.php';
$this->tmpVar = $tmp;
}}Code: Select all
//outputData.php
class outputData {
function outputData(&$testRef) {
echo $testRef->tmpVar;}}Code: Select all
//Main execution stream
include(loadVars.php);
include(outputData.php);
$testObject = new loadVars();
$output = new outputData($testObject);If anyone has any suggestions, I would greatly appreciate it.
Regards,
Shawn