Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0

前端 未结 9 1929
自闭症患者
自闭症患者 2020-12-02 15:44

I am trying to include a php file in a page via

  require_once(http://localhost/web/a.php)

I am getting an error

 Warning:         


        
相关标签:
9条回答
  • 2020-12-02 15:46

    echo file_get_contents('http://localhost/web/a.php'); //Best Example

    0 讨论(0)
  • 2020-12-02 15:47

    WORDPRESS is having this error mostly:
    SOLUTION:
    Locate your PHP installed directory on Remote live hosting SERVER or "Local Server"
    In case of Windows os
    for example if you using xampp or wamp webserver. it will be in xammp directory 'c:\xammp\php'
    Note: For Unix/Linux OS, locate your PHP directory in Webserver

    Find & Edit PHP.INI file
    Find 'allow_url_include'
    replace it with value 'on'
    allow_url_include=On
    Save you php.ini & RESTART you web-server.

    0 讨论(0)
  • 2020-12-02 15:47
    require_once(APPPATH.'web/a.php');
    

    worked for me in codeigniter

    check reference

    0 讨论(0)
  • 2020-12-02 15:52

    The warning is generated because you are using a full URL for the file that you are including. This is NOT the right way because this way you are going to get some HTML from the webserver. Use:

    require_once('../web/a.php');
    

    so that webserver could EXECUTE the script and deliver its output, instead of just serving up the source code (your current case which leads to the warning).

    0 讨论(0)
  • 2020-12-02 15:54

    include and require functions require file path, but you are giving file URI instead. The parameter should not be the one that includes http/https.

    Your code should be something like:

    include ("folder/file.php");
    
    0 讨论(0)
  • 2020-12-02 15:57

    try to use

    <?php require_once($_SERVER['DOCUMENT_ROOT'].'/web/a.php'); ?>
    
    0 讨论(0)
提交回复
热议问题