static class that inhertance nonstatic class in php

In PHP, we can create a static class that inherits from a non-static class by first creating the non-static class and then using the extends keyword to create a new static class that inherits from the non-static class.

Here's an example:

main.php
class MyClass {
    // non-static class code here
}

class MyStaticClass extends MyClass {
    // static class code here
}
123 chars
8 lines

In this example, MyStaticClass is the static class that is inheriting from MyClass, which is the non-static class.

Keep in mind that when using a static class that inherits from a non-static class, you won't be able to access any of the non-static properties or methods of the parent class from the child static class, unless you create an instance of the parent class within the child static class.

related categories

gistlibby LogSnag