Executing php snippets

With the following method, I am able to execute and display a php page:

   def phpstuff
     require ‘net/http’
       url = URI.parse(‘’)
       req = Net::HTTP::Get.new(url.path)
       res = Net::HTTP.start(url.host, url.port) {|http|
      render_text res.body

However, let's suppose I want to simply execute a snippet of php code.
If I am just running straight out of mongrel, on say port 3000 (not
through apache), how can do that? Can I do it in the rhtml somehow?

Also, is there way, from within Rails, to get back a value returned,
say, by executing a method in php? Thanks, Ike

% php -r 'print("hello world\n");'
hello world

If you can call php via the CLI then that would work... kind of ugly, but it would work. You can also just pass it a filename to execute and then parse the results inside of Rails to do whatever you need to do.