Skip to content
Advertisement

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()? Answer If you want to specify a class method as a callback, you need

PHP method chaining or fluent interface?

I am using PHP 5 and I’ve heard of a new featured in the object-oriented approach, called ‘method chaining’. What is it exactly? How do I implement it? Answer It’s rather simple, really. You have a series of mutator methods that all return the original (or other) object. That way, you can keep calling methods on the returned object. This

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 use sessions or cookies at all?

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 class. A property declared as static can not be accessed with an instantiated class object (though a static

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.g. I thought you should always use object methods to access

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 about it behind PHP’s back?

Object-oriented-like structures in relational databases [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 Folks, For the n-th time in a row, i’m hitting the same old problem again. It’s about “how do I map OOP

Advertisement