Hi,
I am having a very strange problem. I wrote a program in php 4.3.10
that
uses objects. My classes.inc file looks like this:
<?php
// Coordinate class
class Coord {
// The variables
var $x;
var $y;
// Get functions to return values
function getX() { return $this->$x; }
function getY() { return $this->$y; }
// Set functions force input to an integer
function setX($int) { $this->$x = round($int); }
function setY($int) { $this->$y = round($int); }
}
// Macroblock class
class Macroblock {
// The variables
var $top;
var $left;
var $diff;
// Get functions to return values
function getTop() { return $this->$top; }
function getLeft() { return $this->$left; }
function getDiff() { return $this->$diff; }
// Set functions to insert values
function setTop($int) { $this->$top = round($int); }
function setLeft($int) { $this->$left = round($int); }
function setDiff($int) { $this->$diff = round($int); }
}
?>
I started getting some strange results in my program when I echoed
various
values. I eventually discovered that every time I used a set function,
it
set every member variable to that value. For example, if I do
$obj_instance->setTop(5) on an object of type Macroblock, then $top,
$left,
AND diff are all set to 5. Does anyone know what is going on?
Thanks,
Erica
http://www.thanksforthemammaries.net