₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,626 members, 8,422,905 topics. Date: Tuesday, 09 June 2026 at 02:31 AM

Toggle theme

Php Experts, Really Need Your Help - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPhp Experts, Really Need Your Help (1274 Views)

1 Reply (Go Down)

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{
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(op): 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(op): 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

To programmers in Nigeria and in the world, I sincerely need your help.Please Guys, I Really Need Some Good Laravel EbooksNairalanders I Really Need Your Help234

Fivver Level 2 For Sale 76 5 Star Reviews!I Need A Good Programmer/javascript Guru In Abeokuta For Quick JobMy Observations