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:
echo file_get_contents('http://localhost/web/a.php'); //Best Example
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.
require_once(APPPATH.'web/a.php');
worked for me in codeigniter
check reference
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).
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");
try to use
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/web/a.php'); ?>