开发者_如何转开发
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this questionSo I would like to create a php editor for the browser, I need it because sometimes I make little test codes what makes my computer messy and I always need to delete or manage those files too and I also would like to split the browser into two frames, the first for PHP the second for the page what is edited so I could see the result, and debug it faster.
But I don't really know how should I make it because PHP needs to be executed, it's not enable to save it like HTML.
If this is for your own, internal use only, you can always eval
the code received via POST - you just need to pass the code as a string to the function. But don't even think about exposing the service for the world, as by default it opens the possibility for malicious user to do almost everything on the server.
Whenever i need to test a snippet of code i just use either the same test.php file in my user dir (Because thats where CMD starts so i dont have to navigate directories etc):
win+r (run) > notepad test.php, save.
win+r > cmd > php test.php
OR just use the -r parameter on the PHP cli interface:
***C:\Users\myuser>php -r*** `for($i=0;$i<10;$i++){ echo ':-)'; }`
:-)
I would use javascript AJAX to send your code using POST to a php page which writes the file. This can happen every few key strokes or when you press a save button. Then when the php file has been saved just make a callback function which starts second AJAX call to a php file which will include the file you have saved just a second ago. It will echo that back to a callback javascript function which will replace a div on the right side of the page you are on with the result. This could also be 2 separate pages. You could make the result come up as a popup that stays open if you want. This would be the basics to make this work.
精彩评论