PHP code example of gcworld / globals

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

    

gcworld / globals example snippets




use GCWorld\Globals\Globals;

$globals = new Globals();

$_GET['page'] = '42';
$_GET['email'] = '[email protected]';

$page = $globals->int()->GET('page');
$email = $globals->email()->GET('email');

$name = $globals->string()->POST('name');

$globals->SESSION('user_id', 42);
$globals->GET('optional', null);

$keys = $globals->getKeys('GET');

$filtered = $globals->GET()->filterAll();
$unfiltered = $globals->GET()->filterNone();

$_GET = [
    'enabled' => 'true',
    'count' => '12',
    'code' => '0012',
];

$enabled = $globals->GET('enabled'); // true
$count = $globals->GET('count');     // 12
$code = $globals->GET('code');       // "0012"

$globals->filter(false);
$value = $globals->GET('value');

$value = $globals->noFilter()->GET('value');

$filtered = $globals->autoFilterManualVar($value);

$_GET['emails'] = [
    '[email protected]',
    'not-an-email',
];

$emails = $globals->array()->email()->GET('emails');

// ['[email protected]', false]

$values = $globals->array(2)->int()->POST('values');

$array = $globals->json(true)->POST('payload');
$object = $globals->json(false)->POST('payload');

$uuid = $globals->uuid()->GET('id');
$bytes = $globals->uuid(true)->GET('id');

$length = $globals
    ->callback(static fn (string $value): int => strlen($value))
    ->POST('name');

$globals->defaults(true);

$page = $globals->int()->GET('missing');       // 0
$emails = $globals->array()->GET('missing');   // []
$date = $globals->date()->GET('missing');      // "0000-00-00"

$globals->utf8(false);