dongyanjing5975 2009-06-02 05:58
浏览 43
已采纳

cli或mod_php中的phpinfo函数有什么区别?

I think that a function called phpinfo is a function displaying environment of PHP, but results of phpinfo which I carried out from a command-line as a result of phpinfo that I displayed it on a Web server are different. Why will these be different? I want to become the same result.

  • 写回答

1条回答 默认 最新

  • doupin2013 2009-06-02 06:28
    关注

    PHP called from your webserver can be configured very differently from your command line PHP.

    It depends on your webserver setup. If you have your webserver simply call your /usr/local/bin/php(or similar) binary then you will have mostly identical output(except without any of the CGI environment variables such as HTTP_HOST, REFERRER, etc.

    On the other hand, if you are using mod_php with apache or php through fast-cgi, your phpinfo will return different values, as mod_php is a separately compiled module for php. It does not call the standard php command that you access through the command line.

    Another possible reason for the differences are that your webserver is using a different php.ini file. The php.ini file tells php what extensions to load, and basically can set most of the parameters that are found on a phpinfo() page.

    It will be hard to make these the same result, unless you can configure your webserver to not send any HTTP headers through to your PHP script, and make sure your php setup for your webserver matches(or directly calls) your command line php build. You can ensure that the php.ini files are the same-- phpinfo() contains the name of the currently loaded configuration file.

    I don't think you'll be able to get them identical regardless, and I don't understand why you want the output to be identical. If you want the settings to be similar, you will want to edit the respective php.ini file to change the settings to what you would like them to be. Also, if you don't have access to the php.ini file, you can use the php function ini_set() to set some configuration varibles at run time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真