Historically, PHP and Ruby do not have the same goal although they both appeared in 1995. The ruby ​​on rails developers choose this because language is object oriented while php is rather to give more dynamism to website. It was only from 2005 that Ruby was then made himself a place in the web languages.

Similarities

Php like in Ruby, typing remains dynamic. That is to say that the developer does not need to declare variables. There are also classes where the management is the same. Some variables start with $, but not all. eval is available in two languages ​​and is even recommended for higher performance and security. The interpolation in the strings and the rest form "# {foo} is a # {bar}" instead of "$ foo is a $ bar" in Ruby. However, this does not work for strings in double quotes. The heredocs are also available for both languages ​​as exceptions for error handling, the relatively standard supplied library, tables and hashes similar or even identical in substance. They have respectively {...} instead of array (). For true and false, they are also identical with only nil instead of null.

The differences

Ruby differs from php by its strong typing. It is actually de rigueur to use methods like to_s, to_i for the types of conversations. Numbers, arrays, hashes, strings and others are all objects. All parentheses are optional in method calls with a recommended use to promote the clarification of affiliation parameters.

The standard library is not organized after naming conventions, but in classes and modules. Reflection does not need to use a class as Reflection but rather an intrinsic ability of objects. Variables are also férérences to objects, but not objects. Ruby has neither interfaces nor abstract classes and tables and dictionaries are not interchangeable. Only false and nil are evaluated false. Just about then a method call.