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"). Quote Link to comment 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. Quote Link to comment 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. 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.