Welcome Guest, Not a member yet? Register   Sign In
how check method exist
#4

[eluser]Colin Williams[/eluser]
I love your response. It's like a puzzle. Here's how you use it (and this has nothing to do with OOP.. it's just a function that says whether the given object has the given method).

Code:
class Frog {

   function Frog()
   {
      print method_exists($this, 'lick') ? 'Frog can lick.' : 'Frog cannot lick';
   }

   function lick()
   {
      print 'Licked.'
   }

}


Messages In This Thread
how check method exist - by El Forum - 10-23-2008, 07:50 PM
how check method exist - by El Forum - 10-23-2008, 08:11 PM
how check method exist - by El Forum - 10-23-2008, 08:33 PM
how check method exist - by El Forum - 10-24-2008, 12:11 AM
how check method exist - by El Forum - 10-24-2008, 02:59 AM
how check method exist - by El Forum - 10-24-2008, 03:10 AM
how check method exist - by El Forum - 10-24-2008, 03:39 AM
how check method exist - by El Forum - 10-24-2008, 03:40 AM
how check method exist - by El Forum - 10-24-2008, 03:51 AM
how check method exist - by El Forum - 10-24-2008, 03:58 AM
how check method exist - by El Forum - 10-24-2008, 08:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB