I have a php code that is procedural. So I am changing it to object oriented. I have a function like this:
<?php
function get_username(){
$user= "maria";
return $user;
}
function get_name(){
$user= "Maria Campbell";
return $user;
}
echo get_username();
echo get_name();
?>
and if I convert it to object oriented, it will be like:
<?php
class user{
public function get_username(){
$user= "maria";
return $user;
}
public function get_name(){
$user= "Maria Campbell";
return $user;
}
}
$userfunctions = new user();
echo $userfunctions->get_username();
echo $userfunctions->get_name();
?>
my question is, what I gain doing the second way? it is the same thing, isnt it?