Speed up development with full-stack environments for every branch.

Learn More

How to open a magic database with finfo_open()

25 Runs 172 Views 26 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php
/**
 * Fileinfo module
 * open a magic database with finfo_fopen()
 */

// open the magic database
$finfo = finfo_open(FILEINFO_MIME,"/usr/share/misc/magic"); 

echo '<center>';
if ($finfo) {
    echo '<div style="background-color:green;padding:10px;color:#fff;font-size:16px;">';
    echo 'Magic database opened!<br />finfo_open returned this resource:<b>';
    var_dump($finfo);
    echo '</b></div>';
} else {
    echo '<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">';
    echo 'Could not open magic database';
    echo '</div>';
}
echo '</center>';

/* close connection */
finfo_close($finfo);
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).