Restrict Visibility and Access

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:04
    Let's keep making our rebel ships work a bit differently than the empires.
  • 0:08
    In this drop-down, you can see a short summary of each ship that is currently functional.
  • 0:13
    It shows their name, weapon power, jedi power, and strength
  • 0:19
    which all comes from the get name inspects function.
  • 0:25
    But I would like a way to tell which ships in this list align with the rebels,
  • 0:29
    so let's add that word in parentheses at the end.
  • 0:33
    As usual to do that, we'll override this in rebel ship. Copy the getNameAndSpecs function
  • 0:39
    and paste it over here.
  • 0:44
    And then just add (Rebel) at the end. Now you may be thinking,
  • 0:51
    guys, that's some serious code duplication. Well, you're absolutely right,
Loading ...

Restrict Visibility and Access

Loading...

In this tutorial, I will show you the difference between public, private, and protected methods or properties in PHP classes. By the end of this lesson you will learn how to make things private at first, protected once you need to access them in a subclass, and public when you need to use it outside of its class and subclass.

Downloads: 
Log in or sign up to download companion files.
Additional resources: