python-php icon indicating copy to clipboard operation
python-php copied to clipboard

Tempfile is unnecessary

Open o11c opened this issue 8 years ago • 4 comments

PHP can execute code directly from stdin, or even from a command-line argument, so the temporary file appears to be pointless.

o11c avatar Apr 01 '16 15:04 o11c

I ran into some bugs with getting the escaping correct when passing the data to PHP from the command line and using a temporary file made debugging a lot easier.

A bigger issue is that the idea of running PHP code from inside of a Python script is total nuts and no one should do it

joshmaker avatar Apr 01 '16 15:04 joshmaker

I feel the temp file route just feels more like idiomatic PHP. Who actually uses the PHP REPL anyway? Is it "really" PHP without the <?php tag? A+, would ruin my life with this!

myers404 avatar Apr 01 '16 21:04 myers404

According to the man page, you only get the interactive REPL if you pass -a or --interactive. With no argument, it parses stdin just like it would parse a file.

o11c avatar Apr 01 '16 21:04 o11c

Also command-line argument can theoretically run into max line length issues if you are trying to pass very large amounts of data to PHP.

joshmaker avatar Apr 02 '16 18:04 joshmaker