-->

PHP Include Function Error, How To Fixed That?

Since PHP5 launched, by default PHP include function has disabled (look at line 580). So if your PHP script / installation have require this function, your browser will showing kind of these error: Warning: include() [function.include]: URL file-access is disabled in the server configuration in -your path-

PHP include have been disabled because in many case thats not safe to remote files with this function. Script with PHP Include will be an open target to cross site scripting attacks (XSS attacks), or other injection that can make your site defaced.



You may usually using include function for grabbing content from other / external source. So what alternative to change Include function so your code can working?

Using file_get_content Function As Alternative

For example, we want to grab CNN latest news, the old include function code:

<?
include ("http://rss.cnn.com/rss/cnn_latest.rss");
?>

Modified / exchange using file_get_content:

<?
$rss = file_get_contents("http://rss.cnn.com/rss/cnn_latest.rss");
echo ($rss);
?>

Download sample PHP CNN Latest news


Related posts:

  1. Problem Solving: Images Not Showing In Virtuemart
  2. How To Managed DNS From Your Own Site
  3. Currency Exchange Free PHP Script


Share To Facebook | Tweet This


 
  • http://peluang-usaha-dari-internet.blogspot.com/ Dedy

    Nice solution to replace include for file get content.. This is useful for shared hosted that came with some restriction

  • http://ninoholic.com El Nino

    Hello Dedy, even you have access to modify php setting / php.ini, you must using include function with the right portion.

    For security reason, there is many suggest to using include function only for including php scripts only.
    Otherwise, for any non php content you should using file_get_contents.

    Please correct me if i’m wrong..

-->