Page 1 of 1

Can I really use methods named like 'stat', 'fopen'?

Posted: Tue Jan 20, 2009 11:26 am
by exesteam
Hello

Looks like PHP works fine even if I use names that are reserved. An example

Code: Select all

class test {
function fopen() {}
function stat() {}
}
No problems? Is this because the class makes a new namespace?

Re: Can I really use methods named like 'stat', 'fopen'?

Posted: Tue Jan 20, 2009 1:11 pm
by Mark Baker
exesteam wrote:Is this because the class makes a new namespace?
Effectively.
If you execute stat() it will still execute the standard PHP stat function.
You can only execute the stat that you've written in your class as $objID->stat() - for an instance of the test class called $objID, or as $this->stat() from within the class.
Even if the method was defined as static, you'd still need to use test::stat() or self::stat()