PHP division by 0

Divide by 0 in PHP How the division by 0 behave in PHP8, PHP7, PHP5 PHP has evolved in the last few years. Before when dividing by 0 we only get a warning. This behaviour did not change until php8, where numeric division 10 / 0 resulted in rasing an Error...

PHP one directional linked list

To create a list, we need to declare two classes, List Node and Linked List classes. Basic PHP one directional linked list PHP Linked list and its methods <?php class ListNode { public $data = NULL; public $next = NULL; function __construct(string $data = NULL) {...

Overriding and overloading methods in PHP

Overriding methods in PHP Overriding and overloading messages in PHP can be a little weird! There are things that will work ant stuff which will not. For example, this method overriding will work: <?php class A { function test(string $s) { echo “$s”; }...
What should you know as a PHP developer?

What should you know as a PHP developer?

As PHP developer, you need to know some common concepts and techniques that help you to write better code and provide solid solutions. It is also important to implement the right tools for the job. Tooling, development practices and development process methodology. If...

WordPress – How to modify archive get_post function?

You can change the get_post function by hooking to pre_get_posts filter. For example, if you have custom post cars, with the archive under www.demo.com/cars and you want to be able to pass a parameter like www.demo.com/cars?year=2020 You would write the fallowing...

PHP Algorithms – factorial

PHP Algorithms – factorial recursive solution <?php /* * EN factorial */ function fact($n){ if($n < 1) return 1; $arr[$n] = $n * fact($n – 1); return $n * fact($n – 1); // 4 * 3 * 2 * 1 } echo fact(4); // 24 PHP Algorithms – factorial...