n4iko Posted August 8, 2010 Share Posted August 8, 2010 It's just a simple question... <?php include ('beginning.txt'); ?> Why can't I include the whole url, eg. ... include ('http://www.mywebsite.com/random/beginning.txt') ... ? It just shows a blank page if I type in the whole url name. I would like to include the file beginning.txt into several pages that are under the folder random. And another question... does it matter if I use ' or ". Some php guides say I should use include ('beginning.txt') some say I should use include ("beginning.txt"). Link to comment https://forums.phpfreaks.com/topic/210133-why-cant-i-include-a-full-url-noob-problem/ Share on other sites More sharing options...
wildteen88 Posted August 8, 2010 Share Posted August 8, 2010 include/require are usually only used for including extra code, such as external functions/classes etc. If you're wanting to get the contents of a text file then use one of the file functions, such as fopen/fread/fclose or simply file_get_contents. Link to comment https://forums.phpfreaks.com/topic/210133-why-cant-i-include-a-full-url-noob-problem/#findComment-1096640 Share on other sites More sharing options...
xangelo Posted August 9, 2010 Share Posted August 9, 2010 The single/double quote thing is irrelevant for what you require. Either will work just as well as the other. If you're just looking for the contents of a file, file_get_contents like n4iko mentioned will work fine. If you absolutely NEED the full path, there is an allow_url_include in your php.ini file that you can turn ON. Link to comment https://forums.phpfreaks.com/topic/210133-why-cant-i-include-a-full-url-noob-problem/#findComment-1097022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.