Jump to content

Why can't I include a full url? (noob problem...)


n4iko

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.