Skip to content

Tag: oop

How do I use a class method as a callback function?

If I use array_walk inside a class function to call another function of the same class It gives me the following error – Warning: array_walk() [function.array-walk]: Unable to call test_print() – function does not exist in … So, how do I specify $this->test_print() while using array_walk(…

PHP Store User Data without Sessions

Is there anyway to store users data such as userid, email, etc to be accessible from all pages of a website after they have logged in, but without using sessions or cookies? For example: after they login at login.php now, how do I access $currentUser from another page, such as index.php if I shouldn’t u…

could static members use nonstatic members and vice versa?

could i use nonstatic members inside a static method? eg. and vice versa that is to say use static members inside non-static methods? Answer From http://php.net/manual/en/language.oop5.static.php Declaring class properties or methods as static makes them accessible without needing an instantiation of the clas…

Is object-oriented PHP slow?

I used to use procedural-style PHP. Later, I used to create some classes. Later, I learned Zend Framework and started to program in OOP style. Now my programs are based on my own framework (with …

OO PHP direct member access [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. Improve this question I always thought you should never set/get a member variable directly. E…

PHP equivalent of send and getattr?

If Ruby gets invited to a party and brings: .. and Python gets invited to the same party and brings: .. what does PHP have to bring to the party? Bonus question: If Ruby and Python got jealous of PHP’s party-favors, what English terms would they search for in PHP’s documentation in order to talk a…