Python:
calc.py
-------
def sum(a, b):
return a+b
hello.py
--------
import calc
print(calc.sum(1, 2))
PHP: 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)
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.