PHP

PHP Iterables – PHP OOP

What is an Iterable in PHP? A value that can be looped through with a foreach() loop is called a “iterable.” PHP 7.1 added the iterable pseudo-type, which can be used as a data type for function arguments and function return values. Example <!DOCTYPE html> <html> <body> <?php function testIterable():iterable { return [“x”, “y”, “z”]; […]

PHP Iterables – PHP OOP Read More »

PHP Namespaces – PHP OOP

PHP Namespaces Namespaces are qualifiers that help solve two different problems: They help keep things more organized by putting together classes that work together to do a task. They let more than one class share the same name. For example, you might have a set of classes that describe an Test table, like Table, Row,

PHP Namespaces – PHP OOP Read More »

Traits PHP OOP

What are Traits in PHP? PHP only allows one type of inheritance, so a child class can only get its traits from one parent class. So, what happens if a class needs to get more than one behavior? This problem can be fixed by OOP traits. With traits, you can define methods that can be

Traits PHP OOP Read More »

Inheritance PHP OOP

What does inheritance mean in PHP? In OOP, inheritance is when a class is based on another class. All of the public and protected properties and methods of the parent class will be passed on to the child class. It can also have its own properties and ways of doing things. The extends keyword is

Inheritance PHP OOP Read More »

Scroll to Top