Tools, FAQ, Tutorials:
Opening Standard Output as a File Handle in PHP
How To Open Standard Output as a File Handle in PHP?
✍: 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 standard 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.
⇒ Working with Directories and Files in PHP
⇐ Reading Data from Keyboard in PHP
2016-11-24, 4759🔥, 0💬
Popular Posts:
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How to create a navigation file like navigation.xhtml for an EPUB 3.0 book? At least one navigation ...
How to create Hello-3.1.epub with WinRAR? I have all required files to create Hello-3.1.epub. To cre...
How to add request query string Parameters to my Azure API operation 2017 version to make it more us...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...