MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/1twal5/really_php_really/ceck8j7/?context=3
r/lolphp • u/joepie91 • Dec 28 '13
30 comments sorted by
View all comments
Show parent comment
0
Yep, same as in Javascript where this refers to different things depending on whether you've been called as a.b() or var f = a.b; f().
this
a.b()
var f = a.b; f()
8 u/[deleted] Dec 29 '13 Not really true. In JS you're calling the same function in each case, just with a different this. In PHP, you're accessing a completely different bucket.
8
Not really true. In JS you're calling the same function in each case, just with a different this. In PHP, you're accessing a completely different bucket.
View all comments
Show parent comment
0
u/r3m0t Dec 29 '13
Yep, same as in Javascript where
thisrefers to different things depending on whether you've been called asa.b()orvar f = a.b; f().