Liquid Fire Posted August 28, 2007 Share Posted August 28, 2007 can i name my class method whatever i want without interfering with defined names? like can i have a method called delete without interfering with the function delete? I would assume this would be possible but my IDE highlights it different so just want to make sure. Quote Link to comment https://forums.phpfreaks.com/topic/67094-class-method-names/ Share on other sites More sharing options...
matthewhaworth Posted August 28, 2007 Share Posted August 28, 2007 can i name my class method whatever i want without interfering with defined names? like can i have a method called delete without interfering with the function delete? I would assume this would be possible but my IDE highlights it different so just want to make sure. I've realised this to, I use PHP Designer 2007 and I was going to name my function fetch, but apparently, there's already one called fetch. I guess it doesn't matter because you always have to have a referrer when referencing the method. I mean, let's say I called my function mysql_connect.. I couldn't actually call that method by typing mysql_connect I'd have to take $class->mysql_connect or $this->mysql_connect or even parent::mysql_connect or class::mysql_connect.. I can never reference it without writing something before it.. therefore I think it's safe to do so, it's just the IDE trying to be clever lol. Quote Link to comment https://forums.phpfreaks.com/topic/67094-class-method-names/#findComment-336648 Share on other sites More sharing options...
Daniel0 Posted September 1, 2007 Share Posted September 1, 2007 You can name it (almost) what you want. PHP has reserved some words which you cannot use: http://php.net/reserved That means that <?php class Test { function echo($string) { echo $string; } } $class = new Test(); $class->echo("test"); ?> will result in: Parse error: syntax error' date=' unexpected T_ECHO, expecting T_STRING in <file> on line 4[/quote'] Quote Link to comment https://forums.phpfreaks.com/topic/67094-class-method-names/#findComment-339266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.