Closed mattsches closed 5 months ago
There's probably many ways to do this... One solution would be to wrap the input (cat -
) in <? ... ?>
and pipe that to PHP:
---
patat:
eval:
php:
command: '(echo "<?"; cat -; echo "?>") | php'
...
# Hello world
Some PHP:
```php
print("Hello, world!");
```
Sorry, it's not working for me. The output is:
# Code Example
print("Hello, world!");
<?
print("Hello, world!");?>
I wonder if there's a way to replace double quotes with single quotes like so: php -r '$foo = get_defined_constants(); var_dump($foo);'
? I can't find a way to achieve this.
It's probably not even a patat
issue, but more of a general bash issue I guess.
I figured out that my PHP installation has disabled the short_open_tags
setting (which is the default nowadays, I guess, but am not sure), so this now works for me:
---
patat:
eval:
php:
command: '(echo "<?php"; cat -; echo "?>") | php'
...
# Hello world
Some PHP:
```php
print("Hello, world!");
Thanks a lot for your support! :smile:
I'm struggling to evaluate PHP code. I suppose the correct command would be
php -r
orphp --run
.results in:
This is probably because of command line variable substitution done by shell as mentioned in the note here (scroll down to the
-r --run
option).Unfortunately, my shell foo is not strong enough to resolve this in the context of patat (or on the command line). Any ideas?