Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,828 members, 7,820,908 topics. Date: Wednesday, 08 May 2024 at 02:03 AM

Php Experts, Really Need Your Help - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php Experts, Really Need Your Help (1146 Views)

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)

(1) (Reply) (Go Down)

Php Experts, Really Need Your Help by updatemachine: 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{
public static $variable = "myValue";
}


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:

$myobj = new Example();
$myobj.variable


I believe it makes more sense now
Re: Php Experts, Really Need Your Help by updatemachine: 4:48pm On Nov 01, 2016
Codenister:
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{
public static $variable = "myValue";
}


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:

$myobj = new Example();
$myobj.variable


I believe it makes more sense now
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:
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..

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:
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{
public static $variable = "myValue";
}


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:

$myobj = new Example();
$myobj.variable


I believe it makes more sense now

Dot operator is Javascript not PHP, You've been writing way too much js.
Re: Php Experts, Really Need Your Help by updatemachine: 5:04pm On Nov 01, 2016
SeunLanLege:


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();
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:


Dot operator is Javascript not PHP, You've been writing way too much js.
Lol, grin my bad
I'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:

Lol, grin my bad
I'm so used to Java actually, I only write a little js
Op, in my original answer the .(dots) should be replaced with ->
Hope you happy now?
And hope you didn't abandon java for php cheesy
Re: Php Experts, Really Need Your Help by Codenister: 7:45pm On Nov 02, 2016
talk2hb1:

Hope you happy now?
And hope you didn't abandon java for php cheesy
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 cheesy

(1) (Reply)

Business Intelligence & Data Warehouse Professional Needed / How Your Business Can Make One Million Naira In One Month. / 14 Year Old Nigerian Mathematical Genius

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.