
Originally Posted by
anode
Ditto.
Mr Tinkles:
I'm not sure why you feel paralyzed that an existing class has a method named the same that you would like to name. Just replace it with your "discount" method. Talk about making a mountain out of a molehill! If this is what you've been arguing about the whole time, I think you need to re-evaluate your priorities.
I have to give mr tinkles credit, you surely are stubborn
. Although I have to question why you would declare an ambiguous function to an object. Before you start slandering that with "Private" and "public" were getting there with PHP5. If PHP is not up to your standards, then why are you coding in it or better yet, why are you coding in a loosely typed language?
Most people will agree that it's learning curve is easier to get round than something like java, but the real reason is it's far more productive in my eye's; quick. Anyway, getting back to your question in hand...
You are obviously losing the plot in many cases, yes poor coding does make any language fail in many apsects, but if you handled something like that, you would check prior for the objects existance "class_exists" and "method_exists". Hopefully with the "new namespaces" in php5 we will have a better solution to this, however you have to stick to the lanuages constructs or all else will fail.
PHP Code:
[font=Courier New]<?php
class a {
function a() {
if(method_exists($this, 'test'))
echo 'a::test() exists!';
else
echo 'a::test() doesn\'t exists';
}
function test() {
return true;
}
}
$b = new a();
?>[/font]
Bookmarks