Hello guys in this opportunity I would like to share this with you.
Ruby and PHP are two languages that have many issues in common. One of theses issues are the classes:
The structure of a class in PHP is the next:
Class classname{
}
And the structure of a class in Ruby is the next:
Class classname
End
In PHP we initialize variables in this way:
Class classname {
Public $var;
}
And the methods are functions of the type:
function myfunction()
The structure of a class for PHP or Ruby has the next parts in according to its depth:
Class name
Definition of Variable (if required)
Functions (in order to establish methods)
Example in PHP:
Class Greetingseverybody {
Function writemytitle()
{
echo "Hello Guys";
}
In Ruby on Rails the class structure in on this way:
Class name
initializacion of variables(if required)
methods (with the structure Def....End)
Example in Ruby:
Class Greetingseverybody Controllermytitle="The title I want"
def writemytitle
puts mytitle
end
This in general the structure of a class in PHP and in Ruby on Rails. In next articles I will write more in depth about classes in PHP and classes in Ruby. Also about the tools to use in order to write better code PHP and Ruby on Rails.
See you soon...
No hay comentarios:
Publicar un comentario