Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Open Standard Output as a File Handle
How To Open Standard Output as a File Handle? - PHP Script Tips - Reading and Writing Files
✍: FYIcenter.com
If you want to open the standard output as a file handle yourself, you can use the fopen("php://stdout") function. It creates a special file handle linking to the standard output, and returns the file handle. Once the standard output is opened to a file handle, you can use fwrite() to write data to the starndard output like a regular file. Here is a PHP script example on how to write to standard output:
<?php $stdout = fopen("php://stdout", "w"); fwrite($stdout,"To do:\n"); fwrite($stdout,"Looking for PHP hosting provider!\n"); fclose($stdout); ?>
This script will print:
What's your name? To do: Looking for PHP hosting provider!
If you don't want to open the standard output as a file handle yourself, you can use the constant STDOUT predefined by PHP as the file handle for standard output.
If you are using your script in a Web page, standard output is merged into the Web page HTML document.
print() and echo() also writes to standard output.
2007-04-23, 4792👍, 0💬
Popular Posts:
Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written...
When does the compiler not implicitly generate the address of the first element of an array? Wheneve...
How To Control Table Widths? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells Usually, b...
What are unadjusted function points and how is it calculated? Unadjusted function points = ILF + EIF...
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...