Home > Article > Backend Development > Why Can't I Use the `finfo` Function in PHP?
Error: PHP fInfo Function Undefined
Issue:
When attempting to retrieve MIME content types using PHP, users encounter fatal error messages such as "Class 'finfo' not found" or "Call to undefined function finfo_open."
Cause and Solution:
The issue stems from the fileinfo extension not being enabled in the PHP configuration file (php.ini).
Resolution:
To resolve this, verify that the following line is present and uncommented in your php.ini file:
extension=fileinfo.so (Linux/Unix) extension=php_fileinfo.dll (Windows)
If the line is missing or commented out (with a semicolon ; at the beginning), uncomment it and restart your PHP web server. This will load the fileinfo extension and make the fInfo functions available.
The above is the detailed content of Why Can't I Use the `finfo` Function in PHP?. For more information, please follow other related articles on the PHP Chinese website!