6

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.

2 Answers 2

20
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

Sign up to request clarification or add additional context in comments.

Comments

2

Just echo vadidation_errors()

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

2 Comments

What if you want to contain the errors in a div. Not each individual divs, but a wrapping div. In that case you need an if statement
@jsheffers You can specify the wrappers in the function params: validation_errors('<div>', '</div>')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.