Php Experts, Really Need Your Help - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Php Experts, Really Need Your Help (1274 Views)
| Php Experts, Really Need Your Help by updatemachine(op): 4:14pm On Nov 01, 2016 |
please, I will like a good explanation of this STATIC keyword in OOP, really dnt get it from various video, ebooks... I got a bit of idea but dnt fully understand when using with this operator :: really frustrating, will like you expert to explain more, so I understand cc: guru01 dhtml18 talk2hb1 seunlanlege fincoapps others.. |
| Re: Php Experts, Really Need Your Help by Codenister: 4:31pm On Nov 01, 2016 |
If a property or method is static, it means it is a class attribute as opposed to being an instance attribute. You will access a class attribute without needing to instantiate the class E.g class Example{The static variable can then be accessed by doing : Example:: variable The same thing for a method. Unlike a situation where you'd have to do:
I believe it makes more sense now |
| Re: Php Experts, Really Need Your Help by updatemachine(op): 4:48pm On Nov 01, 2016 |
Codenister:I think am getting it now... thanks....more input pls.. |
| Re: Php Experts, Really Need Your Help by SeunLanLege(m): 4:53pm On Nov 01, 2016 |
updatemachine:In order to simplify what the ftc said. Static keyword is used when you want to call that function/variable without instantiating the class itself. Class Yay { Public function happy() { Return 'happy'; } } To use the function happy You'll have to instantiate the Yay class //Class yay is instantiated $emotion = new Yay(); $emotion->happy(); Whereas static functions can be called with the class being instantiated. Class Yay { Public static function happy() { Return 'happy'; } } //To access yay Yay::happy(); |
| Re: Php Experts, Really Need Your Help by SeunLanLege(m): 4:55pm On Nov 01, 2016 |
Codenister:Dot operator is Javascript not PHP, You've been writing way too much js. |
| Re: Php Experts, Really Need Your Help by updatemachine(op): 5:04pm On Nov 01, 2016 |
SeunLanLege:Wow! thanks... now I understand.. thanks for ur great contribution! |
| Re: Php Experts, Really Need Your Help by Codenister: 8:28pm On Nov 01, 2016 |
SeunLanLege:Lol, my badI'm so used to Java actually, I only write a little js Op, in my original answer the .(dots) should be replaced with -> |
| Re: Php Experts, Really Need Your Help by talk2hb1(m): 10:11am On Nov 02, 2016 |
Codenister:Hope you happy now? And hope you didn't abandon java for php ![]() |
| Re: Php Experts, Really Need Your Help by Codenister: 7:45pm On Nov 02, 2016 |
talk2hb1:Lol, I have always been happy. I didn't exactly abandon Java for php, but all the serious jobs I have done have been in php. |
| Re: Php Experts, Really Need Your Help by FincoApps(m): 11:26am On Nov 03, 2016 |
OP, you understand well now right ? So no need to explain again ![]() |
To programmers in Nigeria and in the world, I sincerely need your help. • Please Guys, I Really Need Some Good Laravel Ebooks • Nairalanders I Really Need Your Help • 2 • 3 • 4
Fivver Level 2 For Sale 76 5 Star Reviews! • I Need A Good Programmer/javascript Guru In Abeokuta For Quick Job • My Observations
my bad