Using a linux system from today...got my first doubt already
Moderator: General Moderators
-
indian98476
- Forum Commoner
- Posts: 78
- Joined: Tue Dec 15, 2009 3:24 am
Using a linux system from today...got my first doubt already
$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?
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
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?
You do realize it's trying to open an existing file and not create one, right?
-
indian98476
- Forum Commoner
- Posts: 78
- Joined: Tue Dec 15, 2009 3:24 am
Re: Using a linux system from today...got my first doubt already
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
Still looking for clarification about "does not open".
-
indian98476
- Forum Commoner
- Posts: 78
- Joined: Tue Dec 15, 2009 3:24 am
Re: Using a linux system from today...got my first doubt already
'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
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.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
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Using a linux system from today...got my first doubt already
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.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?
(#10850)
Re: Using a linux system from today...got my first doubt already
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....

-
indian98476
- Forum Commoner
- Posts: 78
- Joined: Tue Dec 15, 2009 3:24 am
Re: Using a linux system from today...got my first doubt already
thanx a lot ...i understand now...so how do we display its contents now? write functions again right?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Using a linux system from today...got my first doubt already
Try:
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.
Code: Select all
$file=fopen("Welcome.txt","r");Use echo() to output text to the browser.
(#10850)
-
indian98476
- Forum Commoner
- Posts: 78
- Joined: Tue Dec 15, 2009 3:24 am
Using a linux system from today,got myfirst doubt already-SO
thanx...got it printed 2....