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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
indian98476
Forum Commoner
Posts: 78
Joined: Tue Dec 15, 2009 3:24 am

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

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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?
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

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

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

Post 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....
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

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

Post 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.
User avatar
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

Post 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.
(#10850)
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

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

Post 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
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

Post by indian98476 »

thanx a lot ...i understand now...so how do we display its contents now? write functions again right?
User avatar
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

Post 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.
(#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

Post by indian98476 »

thanx...got it printed 2....
Post Reply