略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: 运行时配置

2024-04-29

运行时配置

此扩展没有在 php.ini 中定义配置指令。

add a noteadd a note

User Contributed Notes 3 notes

up
4
thomandre at gmail dot com
9 years ago
In the PHP 5.3.13 CLI version, it might use the "MAGIC" environnement variable to get the magic database file. Due to the fact that this version doesn't use the standard format, this file may be wrong. You can see it via a simple script :

<?php
    var_dump
($_SERVER['MAGIC']);
?>

Unset this variable and it will work again. You can use unsetenv (C-Shell) or unset (Bourne Shell).

This does not affect the Apache version. Other CLI versions might be affected.

I lost a lot of time on this undocumented issue.
up
1
sam nospam at archives.org.au
12 years ago
In addition to
extension=fileinfo.so
I also had to add
mime_magic.magicfile=/usr/share/file/magic
to my php configuration.  Then, I instantiate Finfo thus:

<?php
$mimeMagicFile
= get_cfg_var('mime_magic.magicfile');
$finfo = new finfo(FILEINFO_MIME, $mimeMagicFile);
?>

(This is despite the rumours I hear about the default being exactly what I set it to anyway.)
up
-1
wade at waddles dot org
13 years ago
On Ubuntu Feisty, you need to add the line

extension=fileinfo.so

to your /etc/php5/*/php.ini files. The extension gets linked at compile time to /usr/lib/libmagic.so.1 which uses a MAGIC environment variable which defaults to

/etc/magic:/usr/share/file/magic

官方地址:https://www.php.net/manual/en/fileinfo.configuration.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3