简体   繁体   中英

CodeIgniter - How to check if there is anything in the validation_error array

I'm wanting to display a general error message if there are any errors in the validation_errors() array, but if I do something like

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

then it returns back and says:

Fatal error: Can't use function return value in write context

Any help would be grand.

if(validation_errors() != false) { echo 'error'; }

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

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

Just echo vadidation_errors()

It will output if there are errors, and nothing if no errors. You don't need if

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM