How to make it global, i.e.
<?php
class Name {
public $errors;
public function validate_form() {
(...)
if ( empty($_POST["blabla"]) ) {
$this->errors = 'Error';
}
(...)
return;
}
}
Then each time you run fucntion in this class, check to see if an error has been generated:
$obj = new Name()->validate_form();
if(isset($obj->errors)){
}
source
share