Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • echo

    Posted on April 17th, 2009 RubyLove 2 comments

    Output one or more strings.

    Strictly speaking, echo() is not a function in PHP, it is a language construct.

    PHP

    echo 'Hello World!';
    // => Hello World!

    Ruby

    print 'Hello World!'
    # => Hello World!
     

    2 responses to “echo”

    1. I think “concat” is actually the real conversion for “echo”.

      Please consider the following:
      <div class=”">…

      The converted:
      <div class=”">…

      “puts” and “print” are -if i’m not wrong- for background usage (eg. terminal, logs, file, …)

    2. hey my comment went corrupted!

      I wanted to add in the two class fields:

      [in php]
      if($cond) echo ‘myclass’;

      [in ruby]
      concat ‘myclass’ if cond

    Leave a reply