11-Sep-2020 : Online PHP editor

  • by

As a fairly inexperienced PHP programmer, I tend to make quite a few mistakes.  Not huge, catastrophic mistakes, just tiny little ones, ones which produce the wrong results or even stop the code running but which won’t bring a Web site down.  Usually.  But just now and again I do something which breaks one of the WordPress theme files, and that often stops my Web site from loading at all.  On one occasion recently I managed to lock myself out for an hour or so whilst I tried feverishly to remember exactly what the last thing was that I did that may have caused it.  All my tinkering was taking place via a cPanel connection to my Web host because that was the only access I had to a PHP system short of setting up a Web server at home.  Or so I thought…

I tend to spend a fair bit of time looking up how to do relatively simple things, and I originally thought that buying a copy of ‘Programming PHP’ by Rasmus Lerdorf & Kevin Tatroe (O’Reilly) was a good investment.  Well, it sort of is because I can sit in front of the TV and read it whilst pretending to be sociable to my long-suffering wife, but to be honest it’s quicker and easier to use Google to find the information I need rather than rifling through a 500-page computer manual, and it’s more convenient as I can then copy and paste any code I need directly into my program.  But I was still constrained to building and testing my code on my Web host’s machine.  I’m not sure what their policy is on allowing their £2.99/month customers to run their own code and, based on the old maxim that it’s easier to seek forgiveness than permission, I thought it was best not to ask.

However I was Googling for some information and I came across a site which not only gave me the answer I was looking for, but it also featured brightly-coloured button which invited me to Try It Yourself, which in turn led me to an online interactive PHP editor, complete with Run button.  I had no idea such things existed!  (You can find it here if you’d like to check it out – it’s very simple to use.)

That set me looking around for an online PHP editor which I could use to carry out the initial develop of my code without going anywhere near my Web host’s server, and after trying half a dozen or so, I settled on the one at https://paiza.io/ which appears to offer not only PHP but also MySQL, Javascript, Visual Basic, Python, Ruby and several others languages.  You can login with your GitHub account and save your code to your usual repository.

I’ve only used it for half an hour or so, so I’m still very much in the process of familiarising myself with it.  Obviously it can’t ‘see’ my Web space, so it can’t read and write files, it doesn’t have access to the PHP mail() function, and there’s probably a load of other things it won’t do, but it seems to be just the job for checking that I’ve got the syntax of my code correct and that it’s doing more or less what I expect it to.

I’m sure there are better online PHP editors out there, but I don’t fancy spending the next three days looking for them.  If you have a personal favourite, please let me know via this contact form or email me and I’ll take a look at it and update this post as and when necessary.