-
Printing output of a string of characters can be done in a variety of ways in Ruby. The equivalent of PHP’s
printconstruct is Ruby’sprintmethod.PHP
print "Hello World"; // => Hello World
Ruby
print "Hello World" # => Hello World
Ruby also has the
putsmethod, which will append a newline to the output.PHP
print "Hello World\n"; // => Hello World
Ruby
puts "Hello World" # => Hello World
To inspect the value of a variable in Ruby we can use the
pmethod. This is similar to performing avar_exportin PHP.PHP
$myVar = array("hello", "world"); var_export($myVar); // => array (0 => 'hello', 1 => 'world')
Ruby
my_var = ["Hello", "world"] p my_var # => ["Hello", "world"]
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

