PHP code example of arthurhoaro / favicon

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

    

arthurhoaro / favicon example snippets




$favicon = new \Favicon\Favicon();

echo $favicon->get('http://hoa.ro');
// Displays: http://hoa.ro/themes/hoaro/img/favicon.png
var_dump($favicon->get('http://nofavicon.tld', FaviconDLType::HOTLINK_URL));
// Returns false

$favicon = new \Favicon\Favicon();

// return the generated filename inside the cache folder
$favicon->get('http://hoa.ro', FaviconDLType::DL_FILE_PATH);
// return false
$favicon->get('http://nofavicon.tld');

$favicon = new \Favicon\Favicon();

// return the binary string of the downloaded favicon
$favicon->get('http://hoa.ro', FaviconDLType::RAW_IMAGE);
// return false
$favicon->get('http://nofavicon.tld');

$favicon = new Favicon();
$settings = array(
    // Cache directory
    'dir' => '/tmp/',
    // Cache timeout in seconds
    'timeout' => 86400,
    // Default image when no favicon is found
    'defaultico' => 'img/fav.ico'
);
$favicon->cache($settings);