Tutorial Details
- Topic: The "Static Keyword"
- Tutorial Format: Article and Video
- Estimated Difficulty: Intermediate
Download Source Files
Today, we are going to learn how to use the ’static’ keyword in PHP. We are going go over the basics and build some examples. It is time to add this interesting language feature to your web development bag of tricks. Become a Premium member today to see this and many other tutorials!
Join Net Premium

For those unfamiliar, the family of TUTS sites runs a premium membership service. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from Nettuts+, Psdtuts+, Aetuts+, Audiotuts+, and Vectortuts+! For the price of a pizza, you’ll learn from some of the best minds in the business. Become a Premium member!


RoyalSlider – Touch-Enable ... only $12.00 
Need my premium..
It happens again – a premium tutorial which is seriously less thorough than a huge number of free tutorials available here. It is somewhat useful, but still, it leaves an impression of a piece written in a hurry, just to fill the premium section with any content whatsoever, justifying the monthly fee.
There was some talk about expanding the Premium section. I believe there will be some improvements coming.
Also, the monthly fee costs less than a movie ticket, which is way more than justified in my opinion.
Thanks for commenting. I really love your articles in the free section, for example the entire CI series, the MySQL-related articles, etc. I think you will agree that they are generally more detailed than the last one in the premium section :-).
I am paying for the premium section mainly as a way to express my support for the quality of the free section, not so much because of what’s inside the premium section. There’s the argument that for USD 9 I get access to all premium content, but well, I’m really into web dev and other sites are of little interest to me, maybe except for psd tuts occassionally.
@Burak, Not if you can find the same thing for free anyways….
And for the newbies and beginners he means…
http://php.net/manual/en/language.oop5.static.php
Also here: http://php.net/manual/en/language.variables.scope.php (scroll down to ‘Using static variables’)
Article and video. Wheres the video? The link only contains a zip file.
Yea, there was supposed to be a video. I just emailed them to remind them. Should be up soon.
The video is there on the Net Premium page guys. :)
Interesting. Ive being contemplating going premium for a while. Still not completely sold yet ;)
A tut’ on static variables isn’t going to make anyone sign up to be fair. There are a lot of free resources that demonstrate and explain static variables very well. Unless there’s some kind of hook a very clever use you’ve used Burak.
As people have said, you’re part in the CI series was brilliant, there are free resources out there for CI but your tut’s tower above the rest and delve into many different aspects of CI in one tutorial.
I’d have to agree on previous comments that there are more extensive free tuts than this premium tut, however, this tut focuses on the static keyword and lets be honest, how extensive can you be?
The tut provides good examples of all cases, and although I ‘thought’ I knew exactly how I to utalise the static keyword both in functions and classes, I still took something away from the very last example.
For beginners, especially those starting to build classes for the first time, this might merit a premium tut (albeit a short one).
Good job Burak.
Hey Burak,
can you do a followup on other oop concenpts in php like how the objects interact with each other and how you would work with abstract classes and more advanced concepts?
-Paul
*sigh*, is this the best premium tutorial you guys get submitted here? This (I am not premium member), is pretty weak in my opinion, its not hard to use static:
public static function helloWorld() {
echo “Hello World!”;
}
myclass::helloWorld();
You even provided the php.net links, I think they are extensive enough.
We need something great for premium, I feel as if Net.tuts is not producing the best anymore, recently, there has been loads of articles about codecanyon items – what is the use?
I don’t want to nag, but I love reading tutorials, and there have been better free/premium (CI series – should of been premium) tutorials on here.
Anyway, lets hope we get some better tutorials on Net.tuts :)
I’m sure this tutorial evolves on what statics are, static methods have a large place in OOP programming, and have many uses
If you try to login on this page, it finds a 404, due to the “‘s in the url me thinks. Just letting you know.