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 = CGI.new
print CGI.header
print ERB.new(ARGF.read).result(binding)
#!/usr/bin/env rubyhp
<!-- Your HTML and eRuby code here -->
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.