Making Ruby into PHP, Take Two

This page was written in response to Christopher Cyll’s Making Ruby into PHP. There’s a slightly more elegant way to do the the same thing:


#!/usr/bin/env ruby

require "cgi" 
require "erb" 

cgi =

print CGI.header

The Script

#!/usr/bin/env rubyhp

<!-- Your HTML and eRuby code here -->

Exception Handling

A slightly more advanced version that captures exceptions and returns information about them is available here:



This code is of course just for learning and not any serious use. I recommend you to base any Ruby web application on Rack.