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

    Posted on April 23rd, 2009 RubyLove 1 comment

    Output a formatted string.

    PHP

    $format = 'There are %d monkeys in the %s';
    printf($format, 5, 'tree');
    // => There are 5 monkeys in the tree

    Ruby

    my_string = 'There are %d monkeys in the %s';
    printf(my_string, 5, 'tree');
    # => There are 5 monkeys in the tree
  • print

    Posted on April 20th, 2009 RubyLove No comments

    Output a string.

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

    PHP

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

    Ruby

    print 'Hello World!'
    # => Hello World!
  • 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!