Current location: Hot Scripts Forums » Programming Languages » PHP » Save to file rather then display it


Save to file rather then display it

Reply
  #1 (permalink)  
Old 07-20-06, 03:51 PM
aGig aGig is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Save to file rather then display it

Greetings,

I am running a php script vis SSH and it gives me the output on the screen. I'd like to have it save to a file on the server. I am willing to pay someone to help me.

I'll paste the end of the code where it spits out the code.
Code:
echo '<','?php',$code,'?','>',"\n";
Thank you.
Reply With Quote
  #2 (permalink)  
Old 07-20-06, 04:25 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
I'll save you the money:

Replace:
PHP Code:

echo '<'.'?php'.$code.'?'.'>'."\n"
With:

PHP Code:

$contents '<'.'?php'.$code.'?'.'>'."\n";


$filename 'path/to/file.txt';

$handle fopen$filename'w' );
echo 
fwrite$handle$contents ) ? 'written' 'failed';
fclose$handle ); 
Aside from minor error checking, that should do it.
__________________
The toxic ZCE

Last edited by Keith; 07-20-06 at 04:28 PM.
Reply With Quote
  #3 (permalink)  
Old 07-20-06, 05:04 PM
aGig aGig is offline
Newbie Coder
 
Join Date: Apr 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Keith... It worked like a charm!

Mark
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking a file exists lee PHP 3 04-23-06 12:44 AM
Error message not getting displayed. sanjeet Windows .NET Programming 0 12-20-05 10:48 AM
fopen() save data on text file?? mhs12grade1992 PHP 1 02-18-05 03:14 PM
How to save .asp.bak file? pikyan ASP 2 10-25-04 02:48 AM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 03:24 AM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.