I am wondering if php methods are ever defined outside the class body, as they are often executed in C ++. I understand that this question is the same as defining class methods in PHP . But I believe that his original question was “declared” instead of “define,” so all the answers seem a little inappropriate.
Update:
My idea of defining and declaring was probably erroneous. But defining outside the body of the class, I had in mind something equivalent to C ++
class CRectangle { int x, y; public: void set_values (int,int); int area () {return (x*y);} }; void CRectangle::set_values (int a, int b) { x = a; y = b; }
All php code examples have code inside the class body, similar to the built-in C ++ function. Even if there wasn’t a functional difference between the two in PHP, it’s just a matter of style.
c ++ oop php class
zenna
source share