9: Static Properties And Methods In Object Oriented PHP | OOP PHP Tutorial | Learn OOP PHP

Php

Video is ready, Click Here to View ×


Static Properties And Methods In Object Oriented PHP | OOP PHP Tutorial | Learn OOP PHP. In this PHP tutorial you will learn about static properties and methods, which are used to access properties and methods without needing to create objects first.

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank…

14 thoughts on “9: Static Properties And Methods In Object Oriented PHP | OOP PHP Tutorial | Learn OOP PHP

  1. BAD EXPLAINED
    A friend of mine is a FullStack developer, he explained me like this.
    public function myNumber() {
    $number = 0;
    $number++;
    }
    Will result with 1. Because 0 + 1 = 1. No matter how many times you run it.. it will always result with 1.
    public static function myNumber() {
    $number = 0;
    $number++;
    }
    Will result also with 1 BUT when you run it a second time, it will result with 2 ! not with 1. You run it a third time, it will result with 3!

    It's like making:

    $number;
    public function myNumber() {
    $number++;
    }

  2. Thank you! I needed the clarification about why it is important to use regular methods or properties instead of static ones, I have that more clear in my head now 😀

  3. If this helps anyone, the way static methods and variables were explained to me was that instead of thinking of them as a class that is going to be instantiated it helps to control name-spaces of HELPER functions and variables, for example you can create a Math class with a bunch of static functions that you can call as a helper later and it's going to be cleaner if you group different helpers in different classes, you can have a Math class, a Statistics class, a Crypto class with static helpers inside so it cleans up the code without needing to instantiating because why would you need the a Math object? It keeps global functions/variables in check through using namespaces.
    NOTE: This is just my understanding which feels to me rather shallow, don't really know how correct this actually is so take it with a grain of salt.

  4. i love your videos, very well explained, but im a little confused on how i apply them in real project. can you please create a tutorial where you are explaining them and creating a simple project at the same time.

  5. Can you show how to use these methods in actual practical examples. Cause if I don't see a end goal to these methods its just staring at how can I change a value in endless modes and shapes. While all that is useful, due to the limitless ways you can program with PHP you need to be more specific. And I kinda understand were you are going with this, I'm just interested in how can I program a website in a modular way so that after I've done the basics (login, content/articles and security) I would want to make sure its scalable. I know I want a lot but that is kinda were the sweet spot is at. Cause if you manage to do that the need for frameworks that are too complicated and too complex to even fix the most of the trivial stuff, becomes pointless.

    Thanks a lot for the tutorials, it had broaden my view of php and what you can do with it. Good luck moving forward!

  6. Hej mmtuts!

    jeg har fulgt hele din php serie samt html & css.
    jeg sidder dog tilbage med et spørgsmål og det er hvordan man redigerer comments uden at forlade siden.
    Du sagde i din video at man skulle bruge javascript/jqery til dette, jeg har kigget rundt på internettet for finde dette samt en forklaring på hvordan/hvorfor.

    Jeg håber du vil lave en video i fremtiden hvori du forklarer hvordan man gør det.

    Mvh. Frederik

Leave a Reply

Your email address will not be published. Required fields are marked *