![]() |
Return self ?
Hi!
You know when you want to use chains in regular classes, you return $this? PHP Code:
PHP Code:
Also, if this is possible, how does the actual chaining work? I mean.. do you use it like: PHP Code:
|
I know I used $this in a situation similar to your first example. In your last example, the actual chaining, I did something like this:
PHP Code:
|
As far as I'm aware, that's not possible at the moment.
|
Quote:
Yes, I know how to do actual chainings with the regular classes, it's just the little problem that this isn't a regular class :-( Quote:
|
I'm interested in why you would try to call the same method over and over like that or was that just kind of for show? Do all the methods have to be static, or could you just implement the static factory method(s) and then normal methods for any others:
ClassName::factory()->meth()->again()\ static chaining wont work because it doesn't use a class instance for reference, it uses a class name |
I don't wanna call the same method over and over xD I just wanted to get my point out, if it was possible to chain static methods
|
@tanax: I understand, and I'm definitely not flaming. Just new to the forum and wanted to post a couple things. Just threw the explanation in for those that might not understand the method chaining process or why static methods cannot be chained. Cheers.
|
Sure np ! I didn't think you were flaming though, I just wanted to make my point more clear if someone didn't understand ^^
|
thought this was a interesting topic so i made a experiment.
I make a class with static functions and used singleton pattern. like so PHP Code:
PHP Code:
output: Yo yo world sup y'all hope it helps 6 years later XD |
I know I used $this in a situation similar to your first example.
__________________________ Abercrombie Sverige Lancel Soldes Nike Free Günstig |
| All times are GMT. The time now is 03:28 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0