1. Go to this page and download the library: Download popphp/pop-utils 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/ */
use Pop\Utils\ArrayObject;
$arrayObject = ArrayObject::createFromJson('{"foo":"bar"}');
echo $arrayObject->jsonSerialize(JSON_PRETTY_PRINT);
use Pop\Utils\ArrayObject;
$arrayObject = ArrayObject::createFromSerialized('a:1:{s:3:"foo";s:3:"bar";}');
echo $arrayObject->serialize();
use Pop\Utils\CallableObject;
$callable = new CallableObject('trim', ' Hello World!');
echo $callable->call(); // Outputs 'Hello World!'
use Pop\Utils\CallableObject;
$callable = new CallableObject(function ($var) { echo strtoupper($var) . '!';});
$callable->addParameter('hello world');
echo $callable->call(); // Outputs 'HELLO WORLD!'
use Pop\Utils\CallableObject;
$callable = new CallableObject(function ($var) { echo strtoupper($var) . '!';});
echo $callable->call('hello world'); // Outputs 'HELLO WORLD!'
use Pop\Utils\CallableObject;
$callable = new CallableObject('MyClass::someMethod');
echo $callable->call(); // Executes the static 'someMethod()' from class 'MyClass'
use Pop\Utils\CallableObject;
$callable = new CallableObject('MyClass->someMethod');
echo $callable->call(); // Executes the 'someMethod()' in an instance of 'MyClass'
use Pop\Utils\CallableObject;
class MyClass
{
protected $str = null;
public function __construct($str)
{
$this->str = $str;
}
public function printString()
{
echo $this->str;
}
}
// Creates an instance of 'MyClass' with the string 'Hello World' passed into the constructor
$callable = new CallableObject('MyClass', 'Hello World');
$myInstance = $callable->call();
$myInstance->printString();