etrader Posted January 31, 2011 Share Posted January 31, 2011 I put the javascript code of ad into a file named ad.html, then call it in php by $ad = file_get_contents("http://mysite.com/ad.html"); echo $ad; But this does not work for file_get_contents("/ad.html") Is there a way to avoid writing the domain name, and just getting the ad from the file in the root folder? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2011 Share Posted January 31, 2011 root folder? Which root folder? A leading slash / on a file system path refers to the root of the current hard disk. If you mean your document_root folder, use - $_SERVER['DOCUMENT_ROOT'] Quote Link to comment Share on other sites More sharing options...
etrader Posted January 31, 2011 Author Share Posted January 31, 2011 I mean the root folder of the domain folder as /public_html/mysite.com/ Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 31, 2011 Share Posted January 31, 2011 is there a reason why you can't use include()? include($_SERVER['DOCUMENT_ROOT']."/ad.html"); Quote Link to comment Share on other sites More sharing options...
spaceman12 Posted January 31, 2011 Share Posted January 31, 2011 to grab the exact code, you need to pace the ad.html in your localhost or the result wont be as what you want if you grab it from other external links. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 31, 2011 Share Posted January 31, 2011 is there a reason why you can't use include()? include($_SERVER['DOCUMENT_ROOT']."/ad.html"); include() makes much more sense. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.