python-php
python-php copied to clipboard
Tempfile is unnecessary
PHP can execute code directly from stdin, or even from a command-line argument, so the temporary file appears to be pointless.
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
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!
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.
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.