473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to store the output as textfile

Hi
i wanna help..While php script running in browsers,the output must stored as text file simultaneously.
i dont know how to do..
can anyone provide me a solution....
Feb 9 '07 #1
2 1097
xwero
99
I think the simplest solution is to define a variable to catch the output to and if it's done write it to the textfile.

[PHP]
$textcontent = '';
for($i=0;$i<10;$i++){
// regular output
echo $i.'<br>';
// catching for file
$textcontent .= $i.chr(10);
}
// php.net code ;)
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $textcontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($textcontent) to file ($filename)";

fclose($handle);
[/PHP]

it's not simultanious but it's very close.
Feb 9 '07 #2
Hi
i wanna help..While php script running in browsers,the output must stored as text file simultaneously.
i dont know how to do..
can anyone provide me a solution....
to store all output to variable you can use ob_ php fucntions
var value, you can store at file at server or print to screen.
Feb 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: francescomoi | last post by:
Hi. Using PHP 4.3.11, I want my script not to write standard output on the webpage, but on a textfile. I tried with: $variableName = 44;
3
by: Avi | last post by:
I need to create a text file that has the data from the 10 tables in the database. The number of fields in the tables exceeds 255 and so I cannot make a new table with all the fields and then...
9
by: Justme | last post by:
Novice programmer needs help with using fgets to read and ignore the first two lines of a file. I've gone thru the previous posting regarding fgets, but none of them seems to help my situation. I...
1
by: kachokaratz | last post by:
well i have a problem in my project..since the contents of my textfile is too long, i was wondering how to output the textfile in such a way that you can divide the contents to be able to output...
13
by: Nirmala123 | last post by:
Hai everybody, how can i redirect tomcat console output into a text file. I want to print all the error output into the textfile.Help me, thanks in advance......
1
by: perdoname | last post by:
Hello, Im trying to implement a program which will split a text file and then parses the elements to an arraylist. My text file looks like that: My program is that: public class Parse {
2
by: Weegee | last post by:
Hello, Just wondering if anyone knew how to run a DOS cmd such as "ping", and get the output to a CString variable to process using MFC? I'm currently using something like: WinExec("cmd /c...
6
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I wanted to store xml in a SQL Server Table How does one go about it???? How does the Insert look like??? If I do it from a textfile or xmldocument? How doe the Select look like if I...
1
by: maryanncanor | last post by:
Hi I would like to know if there is a macro that can export the data from a query to an output textfile that has NO QUOTES. If I run the concatenated query Expr1: & & & & & & & ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.