普通网友 2015-07-06 07:28
浏览 61

PHP FileInfo扩展php.ini覆盖

I'm making use of a GD Library on my application which requires me to modify my php.ini to work. I understand if I uncomment to extension=fileinfo.so the application will work as required, but my challenge is that I don't have access to my shared host server configurations. My question, Is there a way around using ini_set('', '')

Thanks ahead

  • 写回答

1条回答 默认 最新

  • dongyi5817 2015-07-06 08:11
    关注

    Shared hosting has disabled ini_set() function for security reason if the hosting provider turn on ini_set() to you, you can have full access to php variable control, which the hosting provider don't want

    for your purpose, you can do it through .htaccess file within your application root folder

    two directives are permitted using .htaccess

    php_flag <boolean-flag-name> on|off
    php_value <flag-name> <flag-value>
    

    php_flag should be used for on/off values

    For example, the following .htaccess file will disable globals, set the maximum file upload size to 20MB, and allow PHP scripts to run for 10 minutes (600 seconds):

    php_flag register_globals off
    php_value upload_max_filesize 20M
    php_value max_execution_time 600
    

    You can also use ini_set function. in php scripts which allows you to change a setting within your application at runtime. The function accepts two arguments:

    ini_set(flag-name, flag-value),

    Example

    <?php
    ini_set('register_globals', 0);
    ini_set('upload_max_filesize', '20M');
    ini_set('max_execution_time', 600);
    ?>
    

    We can query the php interpreter before changing these value to query, we can use ini_get() method

    ini_get(flag-name) Returns the configuration value. I’d recommend checking your configuration change and taking appropriate action. Don’t assume ini_get() will always work.

    ini_get_all([extension]) Returns all configuration values as an associative array. The optional extension parameter returns options specific to that extension, e.g. ‘allow_url_fopen’.

    get_cfg_var(flag-name) Returns the original configuration value from php.ini (not any overrides set in .htaccess or by ini_set).

    ini_restore(flag-name) Returns a configuration option to its original value.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集