Reputation: 105
I saw a condition like this:
if ((int)method_exists($this, $this->endpoint) > 0)
What's behind this? What's the advantage over the obvious
if (method_exists($this, $this->endpoint))
?
( Source: http://coreymaynard.com/blog/creating-a-restful-api-with-php/ )
Upvotes: 4
Views: 94
Reputation: 668
I don't see any advantage of turning it into an integer. because method_exists already return a boolean. It is a long and useless way of coding.
if statement require a boolean, and method_exists return a boolean, the process added there has the exact same result than using directly method_exists (but waste time and cpu, so please don't do that :D)
Upvotes: 5