Added: 1 year ago
From: JREAMdesign
Views: 6,256
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (14)

Sign In or Sign Up now to post a comment!
  • In fact this isn't a static class. PHP has no static classes. It's just a regular class with static members.

  • How can you use global variables in a static class?

  • @LarsSweden100 I wouldn't do this, but you could do:

    public function xyz() { global $var;

    }

  • @JREAMdesign Thanks it works, but how can I use a variable from a function in another function?

  • @LarsSweden100 Do this:

    public static function dog() { self::$var = 'hello'; } public function cat() { echo self::$var;  }

  • Instantiating!!!!!!!!!!!!

  • This would have been great if you'd explained when and why you'd use a static class over a normal one. What are the benefits? Why do they exist? When should I decide to use one? What are the drawbacks?

  • @thunderpeel2001 Lets say you wanted to create a class of Cats. What if you want to keep track of every cat every time you create one. All you would have to do is create a static variable and in the constructor you would increment it. As far as drawbacks go, it has the same effect (if not worse) than using global variables. Use them but don't abuse them.

  • @thunderpeel2001

    That is probably the only thing missing from his style of teaching.

    If he adds this to all of his videos, I'd guarantee the views would be twice more.

    I realized I should go and read about the purpose of each video, then come and watch.

    Try this link:

    forums.devshed.com/php-develop­ment-5/the-puspose-of-abstract­-classes-851690.html

  • @puaflatmates can't agree you more. i have to do research on my own after every tutorial to get answers of 'why ' questions.

  • @JonnoTheBonno Thanks holmez!

  • Thank you for this!

  • nice tut!

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more