Quote:
Originally posted by Elmore
The function i'm trying to do is inside a class. Does that make any difference?
|
Oh indeed it does! In your case, it's no longer an ordinary function, but rather called a method. But putting naming issues aside, the syntax to call a method is distinctively different to normal function calls.
Quote:
|
None of the functions inside the class have the same syntax that your example has. So, i'm not sure if were talking about the same thing.
|
That is a hard to understand. It would only make sense that the content and actual code of your class methods differ from whackaxe's function. But a class method might look exactly like the one whackaxe posted, so the syntax is ok in general. You might post some examples so we get a better idea where your problem actually lies.
Quote:
|
It's a shopping basket class that i'd like to expand further. All the "calls" to it are made with get.
|
You mean with method calls like $this->getArticle($id)? Or rather that the class' behaviour is defined through the GET variables?
From your post I'm not quite sure if you understand the difference between a function and a method call. Some examples:
PHP Code:
check_out(); // <- normal function call
$cart->addArticle('foo'); // <- calling an object's method
$this->addArticle('foo'); // <- calling a method "addArticle" from inside the class
print ShoppingCart::getVersion(); // <- static method call
BTW, expanding on an existing class is usually done by extending it (like class MyCart extends ShoppingCart). Not sure if that helps you, but it's a useful way to do things.