CodeIgniter - how to check if there is anything in a validation_error array

I want to show a general error message if validation_errors()there are any errors in the array , but if I do something like

if(isset(validation_errors())) { echo 'error'; }

then he goes back and says:

Fatal error: you cannot use the return value of a function in the context of a record

Any help would be great.

+5
source share
2 answers
if(validation_errors() != false) { echo 'error'; }

isset used to determine if a variable is set and is not NULL

Read http://php.net/manual/en/function.isset.php

+18
source

Simply echo vadidation_errors()

It will be displayed if there are errors, and nothing if there are no errors. You do not needif

+2
source

All Articles