Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use buffered I/O or constants #409

Open
danog opened this issue Mar 9, 2020 · 2 comments
Open

Cannot use buffered I/O or constants #409

danog opened this issue Mar 9, 2020 · 2 comments

Comments

@danog
Copy link

danog commented Mar 9, 2020

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.

@dim-s
Copy link
Member

dim-s commented Mar 10, 2020

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.

@danog
Copy link
Author

danog commented Mar 10, 2020

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
Development

No branches or pull requests

2 participants