PHP code example of thomas-squall / utils

1. Go to this page and download the library: Download thomas-squall/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/ */

    

thomas-squall / utils example snippets

 php
class Person {
    public $name;
    public $age;
}

$array = [
    "name" => "MyName",
    "surname" => "MySurname",
    "age" => 27
];

print_r(array_to_object($array, "Person"));
echo PHP_EOL;
print_r(array_to_object($array, "Person", true));
 php
class Person {
    public $name;
    public $age;
}

$json = '{
    "name": "MyName",
    "surname": "MySurname",
    "age": 27
}';

print_r(array_to_object($json, "Person"));
echo PHP_EOL;
print_r(array_to_object($json, "Person", true));
 php
$value = "";

echo get($value, "hello");
 php
$array = [
    "Hello",
    " ",
    "world"
];

dispose($array);
 php
if (is_cli())
    echo "This script is running in the shell";
else
    echo "This script is not running in the shell";