-->

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. PHP Simple Logout Script
  2. How To Insert HTML, Javascript, PHP Code Into Joomla 1.5 Administrator Page
  3. Simple PHP Password Generator
  4. How To Showing All Content Items On Joomla 1.0.xx RSS / Syndication
  5. Server To Server File Transfer With PHP Script


Share To Facebook | Tweet! This


 
2 Comments. Leave Comment Or Trackback.
  1. #1 • Date 19 June 2009, Dedy said:
     

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

    ReplyReply
  2. #2 • Date 19 June 2009, El Nino said:
     

    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..

    ReplyReply

 

Comment With Facebook?

Comment:

 
 
-->