About 931,000 results
Open links in new tab
  1. Is it possible to create static classes in PHP (like in C#)?

    Nov 23, 2016 · 215 You can have static classes in PHP but they don't call the constructor automatically (if you try and call self::__construct() you'll get an error). Therefore you'd have to …

  2. Static variables in PHP - Stack Overflow

    Sep 22, 2011 · The keyword static in the context of classes behave somewhat like static class variables in other languages. A member (method or variable) declared static is associated with …

  3. php - When should I use static methods? - Stack Overflow

    Nov 14, 2015 · static methods in PHP are beneficial when you want to access a method without instantiating a class, since they are part of compile-time. They are ideal for utility functions, …

  4. Can you use static constants inside classes in PHP?

    38 In PHP, static and const are two different things. const denotes a class constant. They're different than normal variables as they don't have the '$' in front of them, and can't have any …

  5. object - PHP 5: const vs static - Stack Overflow

    Nov 6, 2009 · In PHP 5, what is the difference between using const and static? When is each appropriate? And what role does public, protected and private play - if any?

  6. Static class initializer in PHP - Stack Overflow

    I have an helper class with some static functions. All the functions in the class require a ‘heavy’ initialization function to run once (as if it were a constructor). Is there a good practice for

  7. When do I use static variables/functions in php? - Stack Overflow

    I am refreshing myself on OOP with PHP and I saw an example of setting functions and/or variables as static. When and why would I set a variable/function to static?

  8. php - call a static method inside a class? - Stack Overflow

    Feb 5, 2010 · If you have no object but just call a static method and in that method you want to call another static method in the same class, you have to use self::. So to avoid potential …

  9. php - When to use static vs instantiated classes - Stack Overflow

    Jul 27, 2009 · In PHP, classes are global symbols, so every time you call a static method you rely on a global symbol (the class name). This is a case when global is evil. I had problems with …

  10. How to initialize static variables with a function call?

    Instead of finding a way to get static variables working, I prefer to simply create a getter function. Also helpful if you need arrays belonging to a specific class, and a lot simpler to implement.