PHP code example of tasoft / operation-overload
1. Go to this page and download the library: Download tasoft/operation-overload library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tasoft / operation-overload example snippets
var_dump( extension_loaded('tasoft_usr_op_overload') ); // Should be true
use TASoft\Util\OperationOverloadingObject;
use TASoft\Util\OperationOverloadingObject as OpOv;
class Number extends OpOv {
private $number;
public function __construct($number) {
$this->number = $number;
}
public static function __add($op1,$op2){
if($op1 instanceof Number)
$op1 = $op1->number;
if($op2 instanceof Number)
$op2 = $op2->number;
return $op1 + $op2;
}
}
$n1 = new Number(23);
$n2 = new Number(18);
echo $n1 + $n2; // 41
bin
$ php --ini