PHP to Ruby
Convert PHP code into Ruby!
-
printf
Posted on April 23rd, 2009 1 commentOutput 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 No commentsOutput 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 2 commentsOutput 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!


