Skip to content

Cannot use buffered I/O or constants #409

Open

Description

@danog

Cannot open the buffered I/O php://input and php://output constants.
Also, the STDIN, STDOUT and STDERR constants that should set to be already-opened php://stdin, php://stdout, php://stderr streams are just strings.

Code:

<?php

var_dump(\STDIN);
var_dump(\STDOUT);
var_dump(\STDERR);

var_dump(fopen('php://input', 'r'));
var_dump(fopen('php://output', 'w'));

var_dump(fopen('php://stdin', 'r'));
var_dump(fopen('php://stdout', 'w'));
var_dump(fopen('php://stderr', 'w'));

Result:

[daniil@daniil-arch jav]$ jppm start
-> linux
-> app:run 
-> install 
string(5) "STDIN"
string(6) "STDOUT"
string(6) "STDERR"
Warning: fopen(): failed to open stream, null in 'res://7.php' on line 6 at pos 10
bool(false)
Warning: fopen(): failed to open stream, null in 'res://7.php' on line 7 at pos 10
bool(false)
object(php\io\MiscStream)#1031061344 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(5) "stdin"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "r"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}
object(php\io\MiscStream)#686466458 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(6) "stdout"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "w"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}
object(php\io\MiscStream)#875016237 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(6) "stderr"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "w"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}

The buffered I/O streams can just be linked to stdin and stdout, like they normally are on PHP CLI.

Activity

  1. dim-s commented on Mar 10, 2020

    @dim-s
    Member

    Regarding php://input, I don’t really understand how to integrate this into the engine, because jphp does not implement web functionality as in the original php.

  2. danog commented on Mar 10, 2020

    @danog
    Author

    Yeah, it's a bit tricky.
    You could link it to php://stdin, or to an empty stream like zend PHP does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions