PHP code example of fleshgrinder / value

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

    

fleshgrinder / value example snippets




use Fleshgrinder\Core\Value;

$closed_resource = tmpfile();
fclose($closed_resource);

$values = [
	[],
	true,
	1.0,
	1,
	null,
	new stdClass,
	new DateTimeImmutable,
	tmpfile(),
	$closed_resource,
	'string'
];

foreach ($values as $value) {
	echo Value::getType($value) , "\n";
}




use Fleshgrinder\Core\Value;

echo Value::TYPE_ARRAY;             // array
echo Value::TYPE_BOOL;              // boolean
echo Value::TYPE_CALLABLE;          // callable
echo Value::TYPE_CLOSED_RESOURCE;   // closed resource
echo Value::TYPE_FLOAT;             // float
echo Value::TYPE_INT;               // integer
echo Value::TYPE_ITERABLE;          // iterable
echo Value::TYPE_NULL;              // null
echo Value::TYPE_OBJECT;            // object
echo Value::TYPE_RESOURCE;          // resource
echo Value::TYPE_STRING;            // string

$type = is_object($arg) ? get_class($arg) : gettype($arg);

$type = Value::getType($arg);