This seems like the most basic thing in the world, but I don’t know PHP.
I am trying to include a file on my page, and the directory of that file is specified inside of a variable.
<?php
$pageGroup = 'news';
$directory = 'http://localhost:8888/includes/'.$pageGroup.'/rightCol.html';
include($directory);
?>
When I echo the results of $directory, I get “http://localhost:8888/includes/news/rightCol.html“, which is exactly right. Yet when I try to include the file at that directory, nothing happens. I am assuming this has something to do with the include syntax.
Any suggestions are appreciated.
Make sure that you have
allow_url_fopensettings turned on from php.ini.Having said that, there are security risks attached to that, see:
Suggestion:
To include files, don’t use complete url path, use just file/folder paths.
Example:
To include files from root, you might want to prefix your path with: