<?php require_once __DIR__ . "/../vendor/autoload.php"; use phpbrowscap\Browscap; use phpcaniuse\CanIUse; $bc = new Browscap('/tmp'); $browser = $bc->getBrowser(); $can = new phpcaniuse\CanIUse($browser, file_get_contents("../data.json")); echo "supported:" . $can->check(array('fontface', 'video')) . "<br>"; echo "browser<br><textarea rows=25 cols=80>" . var_export($browser, true) . "</textarea>"; echo "<br>getInfo<br><textarea rows=10 cols=80>" . var_export($can->getInfo(), true) . "</textarea><br>"; echo "<br>browserCan<br><textarea rows=25 cols=80>" . var_export($can->browserCan(), true) . "</textarea><br>"; echo "<br>featureList<br><textarea rows=25 cols=80>" . var_export($can->featureList(), true) . "</textarea><br>"; echo "<br>raw data<br><textarea rows=25 cols=80>" . var_export($can->dataGet(), true) . "</textarea>"; echo "\n<br>fin<br>\n";
<body style="font-family:sans-serif"> <?php require_once __DIR__ . "/../vendor/autoload.php"; use phpbrowscap\Browscap; use phpcaniuse\CanIUse; //get the temp dir $tmp = sys_get_temp_dir(); //initialize the browscap object $bc = new Browscap($tmp); $browser = $bc->getBrowser(); //if we don't have json data, then get it if (!file_exists("{$tmp}/data.json")) { file_put_contents("{$tmp}/data.json", file_get_contents("http://raw.github.com/Fyrd/caniuse/master/data.json")); } //now initialize the canIUse object $can = new phpcaniuse\CanIUse($browser, file_get_contents("{$tmp}/data.json")); //now start building output ?> <table> <tr> <td><a href="#browscapproperties">Browscap Properties</a></td> <td><a href="#caniusefeaturelist">CanIUse Feature list</a></td> <td><a href="#browsersupportedfeatures">Browser Supported Features</a></td> </tr> </table> <?php //browscap $browserArray = get_object_vars($browser); echo "<h1><a name='browscapproperties'>Browscap properties</a></h1>"; echo "<table><tr><th>Property</th><th>Value</th></tr>" . array_to_table($browserArray) . "</table>";