why my php doesnt support class?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bigjl
Forum Newbie
Posts: 15
Joined: Fri Jan 13, 2006 11:15 am

why my php doesnt support class?

Post 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
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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();
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

. is used for string concatenation in PHP. A bit confusing I know.
Post Reply