1

I am aware that there are services like

... where you can post a PHP snippet, get a unique URL id for it, and run it on the page itself - and even link to the raw source version of the code (as in the above example).

However, I am not aware of any such service, that also serves PHP code - say if my PHP code snippet is just echo "test"; - then at some form of the URL with that ID I should get just the string test (the result of executing the PHP code). Apparently PHPFiddle had that once, as http://phpfiddle.org/api/run/e965-kbf2 responds with "This API was disabled as security reasons" - but it doesn't have it anymore.

So are there such services - where you can both post/share and run/serve PHP code - in existence? I simply need to write an example for a forum, where I can both share the code, and use the output in a JS example.. I would be OK if this service has limits on how many seconds the script is allowed to execute, or how much memory it is allowed to use...

1 Answer 1

1

Actually, there does seem to be a way with PhpFiddle APIs version 3.0 http://phpfiddle.org/deposit/phpfiddle_apis.php - but not with saved snippets; you can send the code in a POST request, and you will get a JSON encoded response (string output only).

So with curl in a Linux bash shell, one can do:

curl --data "phptag=yes" \
 --data-urlencode 'code=$a=array("One", "Two", "Three"); echo json_encode($a);' \
 http://phpfiddle.org/api/run/code/json

... and the response will be:

{"result":"[\"One\",\"Two\",\"Three\"]"}

(It's slightly more difficult to do this with wget, since it doesn't urlencode its POST parameters)

1
  • Don't forget to accept your own answer (the system will let you do so after two days), in order to help others who read this question in the future.
    – Mawg
    Commented Jan 25, 2018 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.