Page 1 of 1

why my php doesnt support class?

Posted: Fri Jan 27, 2006 6:21 am
by bigjl
I got RHLE4 on my machine. php 4.3+. please help me with the problem shown below
fragment of class:
class Queue {
var $q_array = array();
function push($object) { array_push($this->q_array,$object);}
..............
}

php fragment:
<?php
$queue = new Queue;
$queue.push("1");
......................
?>
error message:
Fatal error: Call to undefined function: push() in /var/www/html/scott/run_hits.php on line 2

Posted: Fri Jan 27, 2006 6:29 am
by Jenk
PHP uses '->' instead of '.' to signy a child method/property :)

And don't forget you must have the class definition within the same environment, be it through an include or in the same file.

Code: Select all

$queue->push();

Posted: Fri Jan 27, 2006 7:35 am
by Maugrim_The_Reaper
. is used for string concatenation in PHP. A bit confusing I know.