YourNameHere Posted April 21, 2010 Share Posted April 21, 2010 I have a class that's called 'page' within 'page' there is a method called 'load' It loads a 'template'. which is just an html or php page within the views directory. load takes two parameters, $page_name, $views_directory. function load($page_name, $views_directory) { include_once($views_directory.$page_name); } This is from my production server: so when I use $page->load('main.php', 'http://localhost/hatrixx/views/'); it fails with this error. http:// wrapper is disabled in the server configuration by allow_url_include=0 in... I have access to the php.ini on my dev server but I wont on the production server so I don't want to just change that variable. Will it work on my production server and/or is there a way around this? Link to comment https://forums.phpfreaks.com/topic/199326-allow_url_includes-issue/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 21, 2010 Share Posted April 21, 2010 Why would you want to include a local file using a URL? That takes 50-100 times longer than including it using a file system path because with a URL your web server must make a http request back to your web server to request the page, the same as if you browsed to the URL. Link to comment https://forums.phpfreaks.com/topic/199326-allow_url_includes-issue/#findComment-1046153 Share on other sites More sharing options...
YourNameHere Posted April 21, 2010 Author Share Posted April 21, 2010 Why would you want to include a local file using a URL? because the url will be in a config file using a $base_url.'views/' this class is a helper class to make coding faster. and the views/ dir may be different with each application. But I just used a bunch of if/ifelse statement to find the /views/ directory and it works. function load($template, $base_url) { if (is_dir('/views/')) { $inc_views = '/views/'; } elseif (is_dir('../views/')) { $inc_views = '../views/'; } elseif (is_dir('../../views/')) { $inc_views = '../../views/'; } elseif (is_dir('../../../views/')) { $inc_views = '../../../views/'; } elseif (is_dir('../../../../views/')) { $inc_views = '../../../../views/'; } include_once($inc_views.$template); } Link to comment https://forums.phpfreaks.com/topic/199326-allow_url_includes-issue/#findComment-1046166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.