The very basics
The Ruby language is object-oriented.
PHP is not object-oriented, but has objects. Ruby’s object-oriented nature results in some areas of it’s syntax to look very much like JavaScript.
PHP’s
echo is
puts in Ruby.
PHP uses semicolons. Ruby uses semicolons, but only in specific cases. For clean, readable code, assume you won’t be needing semicolons. Lets being…
The Basics
PHP creates arrays and hashes with the same function
array().
1
2
3
4
5
6
|
# PHP
$array = array('my', 'php', 'array');
$hash = array(
'my_index'=>'my_value',
'my_second_index'=>'my_second_value'
); |
Ruby handles arrays and hashes separately.
1
2
3
4
5
6
|
# Ruby
array = ['my','ruby','array']
hash = {
'my_index'=>'my_value',
'my_second_index'=>'my_second_value'
} |
Read the rest of this entry