I'm learning PHP OOP and Im trying to understand why the following script doesn't work:
class ShowTimeline {
var $conn;
var $rev;
function getTimeline ($conn) {
return $this->conn;
}
function reverseTimeline () {
$rev = array_reverse($this->conn, false);
return $rev;
}
function display () {
$this->reverseTimeline();
print_r($this->rev);
}
}
print '<hr />';
$connect = new showTimeline();
$connect->conn = array('one', 'two', 'three');
$connect->display();
When I change the script to:
//same stuff above
function display () {
$this->reverseTimeline();
print_r($this->conn); //changed from $this->rev
}
//same stuff below
I get the print out:
Array ( [0] => one [1] => two [2] => three )
which is correct. Please help?