In fact, it's just a syntax error ...
<?php
class Calculadora {
# Definindo função soma
public function somar($num1, $num2){
$resultado=$num1+$num2;
return $resultado;
}
# Definindo função multiplica
function multiplicar($num1, $num2){
$resultado=$num1*$num2;
return $resultado;
}
}
$obj = new Calculadora();
echo $obj->multiplicar(5,8); // 40
echo $obj->somar(5,8); // 18
See that you should instantiate the object Calculadora
out of its declaration.
Calls must also be made outside the scope of the object.