Exemplo n.º 1
0
<?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";
Exemplo n.º 2
0
<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>";
//features
echo "<h1><a name='caniusefeaturelist'>CanIUse Feature list</a></h1>";
echo "<table><tr><th>Key</th><th>Description</th></tr>" . array_to_table($can->featureList()) . "</table>";
//browser supported features
echo "<h1><a name='browsersupportedfeatures'>Browser Supported Features</a></h1>";
echo "<table><tr><th>Feature</th><th>Status</th></tr>" . array_to_table($can->browserCan()) . "</table>";
?>

</body>
</html>

<?php 
function array_to_table($arr)
{
    $out = "";
    foreach ($arr as $key => $value) {
        $out .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
    }
    return $out;
}