|
Posted by rfhurley on 01/17/07 01:49
Thanks for writing. OK, I was able to use the include/require()
commands; what I am wondering though, is in what context would you use
the fopen() command as opposed to using the other commands you
mentioned? The tutorial had nothing to say on that subject. Also, the
fopen() command has "write" and "append" modes. How would this work?
(Also, I tried using the "echo" command following the fopen() command:
$file=fopen("welcome.txt","r");
echo $file;
It didn't work-- I presume because I wasn't using it correctly)
Thanks again for the advice!
Rob
> rfhurley wrote:
> > I'm a newbie at this, etc...
>
> fopen() returns a resource (in essence a 'link' to the file), not the
> actual contents.
>
> Furthermore, you don't output anything to the browser, you just tell php to
> open a file, and then.... nothing.
>
> Following a fopen() is usually an fread() <http://www.php.net/fread>, and
> to output stuff to the browser something like 'echo' or 'print' is used.
> PHP cannot control your computer (i.e. open Notepad), it can only perform
> actions on the server it runs on, and report back, usually to a browser by
> http.
>
> To get the contents of welcome.txt in your html page, you could include()
> or require() it, you could use file_get_contents()/readfile() (essentially
> a shortcut for fopen() & fread()) in combination with an echo, and several
> other options.
> --
> Rik Wasmus
Navigation:
[Reply to this message]
|