PHP needs modules. The way it solves code reuse by tooling that helps making class names longer to avoid collisions is just too cumbersome.<p>Python:<p><pre><code> calc.py
-------
def sum(a, b):
return a+b
hello.py
--------
import calc
print(calc.sum(1, 2))
</code></pre>
PHP:<p><pre><code> LongUniqueStringToHopefullyAvoidCollisions/Calc.php
---------------------------------------------------
<?php
namespace LongUniqueStringToHopefullyAvoidCollisions;
class Calc {
public static function sum($a, $b) {
return $a + $b;
}
}
hello.php
---------
<?php
require_once 'LongUniqueStringToHopefullyAvoidCollisions/Calc.php';
use LongUniqueStringToHopefullyAvoidCollisions\Calc;
echo Calc::sum(1, 2)
</code></pre>
For people who don't know PHP it is probably hard to grasp and hard to believe: To avoid name collisions, you have to wrap your code in classes and then use the "namespace" and "use" keywords which function like prefixing the class names with a given string, so the class names hopefully do not collide with other class names in your codebase.