1. Go to this page and download the library: Download sahil-gulati/overloading 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/ */
sahil-gulati / overloading example snippets
OverloadingTest extends Overloading\Overloading
{
public $x="";
public $y="";
public function __construct()
{
parent::__construct(
func_get_args(),
function($x) {
$this->x=$x;
echo "Setting the value of x";
},
function($x,$y) {
$this->x=$x;
$this->y=$y;
echo "Setting the value of x and y";
}
);
}
public function declareFunction()
{
parent::__declare_testing_function(function($x){
$this->x=$x;
echo "X will be replaced by new value.";
});
parent::__declare_testing_function(function($x,$y){
$this->x=$x;
$this->y=$y;
echo "X and Y will be replaced by new values";
});
}
}
try
{
$obj =new OverloadingTest("s");
$obj->declareFunction();
$obj->testing_function("s","g");
} catch (\Overloading\Exception\Exception $ex) {
echo $ex->getErrorMessageForCode();
}
parent::__construct(
func_get_args(), //array of arguments passed in constructor**
function($x) { //constructor definition 1.**
$this->x=$x;
echo "Setting the value of x";
},
function($x,$y) { //constructor definition 2.**
$this->x=$x;
$this->y=$y;
echo "Setting the value of x and y";
}
//..,
//..,
//..
);
parent::__declare_FUNCTION_NAME(function($x) { //FUNCTION_NAME is name of function to define**
echo "In function FUNCTION_NAME";
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.