Home  >  Article  >  Backend Development  >  Why Can't I Use the `finfo` Function in PHP?

Why Can't I Use the `finfo` Function in PHP?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-15 22:22:03258browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn