Count errors in wordpress -
how count correctly errors in wordpress?
so far tried this:
if(count( $errors )==0) echo 'no errors'; else 'some errors'; but not working, display everytime: errors.
i did var_dump($errors):
object(wp_error)#180 (2) { ["errors"]=> array(0) { } ["error_data"]=> array(0) { } } please tell me how correctly, count errors.
empty( $errors ) returns false
you may confusing things creating wp_error object called $errors has property called $errors. if use:
if(count( $errors->errors )==0) echo 'no errors'; else echo 'some errors'; i think you're calling count on wp_error object rather $errors array property. when count object in php, according to manual:
if var not array or object implemented countable interface, 1 returned. there 1 exception, if var null, 0 returned.
i'm guessing wp_error object without implemented countable interface, you'll value 1 if count() one.
Comments
Post a Comment