I made my transition from Java to PHP and recently ran into something I used to do in Java but I'm not able to do it in php.
The following code creates an object of type "User"
public function validateUser() {
//Check if information entered by user is valid
$user = new User($_POST);
new UserControl($user);
}
I need to validate if cpf is numerical, before proceeding with validation with the formula. In Java I would use something like:
int cpf = this.getUser().getUserCpf();
The code in php looks like this:
class UserControl {
private $user;
public function __construct($user) {
$this->setUser($user);
}
public function validateIntegers() {
$cpf = $this->getUser()->getUserCpf();
is_numeric($cpf);
}
But the same logic does not apply. Is there any other way to use this object orientation in PHP? Or is it not possible to do something like this?