project-nz Posted May 13, 2009 Share Posted May 13, 2009 hi is it possible to call a function inside a function for example wheneva i try the following code it comes up with error class Listings { function Listings() { MakeCon(); } function MakeCon(){ } } Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/ Share on other sites More sharing options...
trq Posted May 13, 2009 Share Posted May 13, 2009 That is because your also within a class. class Listings { function Listings() { $this->MakeCon(); } function MakeCon(){ } } Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/#findComment-833057 Share on other sites More sharing options...
project-nz Posted May 13, 2009 Author Share Posted May 13, 2009 thanks different from other languages Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/#findComment-833064 Share on other sites More sharing options...
trq Posted May 13, 2009 Share Posted May 13, 2009 I think you'll find its not. Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/#findComment-833089 Share on other sites More sharing options...
project-nz Posted May 13, 2009 Author Share Posted May 13, 2009 I think you'll find its not. yes it is why would you need to say 'this' when it knows its referencing functions inside the class? Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/#findComment-833120 Share on other sites More sharing options...
trq Posted May 13, 2009 Share Posted May 13, 2009 I think you'll find its not. yes it is why would you need to say 'this' when it knows its referencing functions inside the class? Show me a language that doesn't use some sort of reference within a class definition to point an instance of that object to the right place. python class foo: def bar(self): print "this is bar" def bob(self): self.bar() ruby class foo def foo.bar() puts "this is bar" end def bob() foo.bar() end end I'm not saying all languages work this way, but most do. Link to comment https://forums.phpfreaks.com/topic/157936-solved-call-function-inside-function/#findComment-833134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.