Created
October 24, 2012 13:11
-
-
Save jubianchi/3945969 to your computer and use it in GitHub Desktop.
PHP & STDOUT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
var_dump(defined('STDOUT')); | |
var_dump(@fopen('php://stdout', 'w')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## PHP 5.3.15 | |
$ php ./stdout.php | |
# bool(true) | |
# resource(5) of type (stream) | |
$ curl -s file://`pwd`/stdout.php | php | |
# bool(false) | |
# resource(2) of type (stream) | |
## PHP 5.4.5 | |
$ php ./stdout.php | |
# bool(true) | |
# resource(5) of type (stream) | |
$ curl -s file://`pwd`/stdout.php | php | |
# bool(false) | |
# resource(2) of type (stream) | |
$ echo '<?php var_dump(defined("STDOUT"));' | php | |
# bool(false) |
Note: that page is the second result for https://www.google.com/search?complete=0&q=php+stdout
I read these pages but I was asking what is the point of this behavior ?
Piping to PHP means that it does not have an actual STDOUT ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I do not get your problem. http://php.net/manual/en/features.commandline.io-streams.php clearly says These constants are not available if reading the PHP script from stdin.