Download: Code Runner for Visual Studio Code
I have been developing WordPress as well as writing the best language of the world for over 1 year. Sometimes, I write or get a small piece of PHP code and want to run it immediately to see whether it works as expected or how it works. Unfortunately, I always forget whether it is
php -f or
php -r to run a php file or php code snippet. I need to Google it and then open a shell and then type the command and then copy/paste the code snippet and then run it. Therefore, I decide to write this extension.😁
The most useful point of this extension is that you could select some lines of code and then kick off the run immediately. To implement this, I just need to create a temp file with the selected code, then call the corresponding interpreter to run the file. All languages should work well without any special handling, except PHP and Python. 😦 Yes, you know. For PHP, the PHP file need to start with
<?php. But how about the selected php code snippet? They may not have the
<?php at the beginning. No problem, just add it if there’s no
<?php to resolve this. And for Python? 🙂 Currently, I haven’t dealt with it because I do not want to do too much special handling for its amazing code style. But if users really want the full support for Python, I may consider supporting it as well.