Page 1 of 1

Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 3:25 am
by indian98476
$file=fopen("welcome.txt","r");

this code is in a simple php file...but the file 'Welcome.txt' does not open in any editor...is it because i am using a linux os?

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 3:49 am
by requinix
You'll have to be more specific than "does not open".

You do realize it's trying to open an existing file and not create one, right?

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 4:08 am
by indian98476
yes i created a file named 'Welcome.txt' in the same folder as where this say , test.php resides...is there anything which i have missed to code in?

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 4:25 am
by requinix
Still looking for clarification about "does not open".

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 4:28 am
by indian98476
'does not open' means the file 'Welcome.txt' should have opened after running this code....and since its a text file i expected to see some editor pop up the file.....but nothing happened....the page returns a blank page...the script executes....that's it....

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 5:38 am
by Weirdan
indian98476 wrote:'does not open' means the file 'Welcome.txt' should have opened after running this code....and since its a text file i expected to see some editor pop up the file
It won't do so on any operating system. fopen() creates a stream resource (attached to the file) which you can later pass to functions like fread(), fwrite(), etc. It's not supposed to pop up in any sort of editor.

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 5:55 am
by Christopher
indian98476 wrote:$file=fopen("welcome.txt","r");

this code is in a simple php file...but the file 'Welcome.txt' does not open in any editor...is it because i am using a linux os?
You code is trying to open "welcome.txt", but you said you created a file 'Welcome.txt'. Remember that file names in Unix file systems are case sensitive, unlike Windows.

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 6:14 am
by panic!
indian98476 wrote:'does not open' means the file 'Welcome.txt' should have opened after running this code....and since its a text file i expected to see some editor pop up the file.....but nothing happened....the page returns a blank page...the script executes....that's it....
Image

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 6:55 am
by indian98476
thanx a lot ...i understand now...so how do we display its contents now? write functions again right?

Re: Using a linux system from today...got my first doubt already

Posted: Tue Dec 22, 2009 12:21 pm
by Christopher
Try:

Code: Select all

$file=fopen("Welcome.txt","r");
See the manual for reading from the file. http://us3.php.net/manual/en/function.fread.php

Use echo() to output text to the browser.

Using a linux system from today,got myfirst doubt already-SO

Posted: Tue Dec 22, 2009 10:45 pm
by indian98476
thanx...got it printed 2....