PHP code example of shieldfy / sniffer
1. Go to this page and download the library: Download shieldfy/sniffer 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/ */
shieldfy / sniffer example snippets
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff('12.5'); //number
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff('hello world'); //string
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(json_encode(['hello'=>1,'world'=>'!'])); //json
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(serialize(['hello'=>1,'world'=>'!'])); //serialize
//you can add more than value as array
$type = (new \Shieldfy\Sniffer\Sniffer)->sniff(['555','abc']);
//test against particular type
$result = (new \Shieldfy\Sniffer\Sniffer)->is('123456789','number'); //true
//you can register your own sniffer on the runtime
$type = (new \Shieldfy\Sniffer\Sniffer)->register('hello',function($input){
if(strstr($input,'hello'))
return true;
return false;
})->sniff('say hello world');