检查变量是否在Kohana视图中定义时的未定义变量

I'm running into this error when loading up my view:

ErrorException [ Notice ]: Undefined variable: errors
APPPATH\views\admin\category\add.php [ 2 ]

<h3>Add</h3>  
<?php if( $errors ): ?>
<p><?=$errors?></p>
<?php endif; ?>

How is my checking not valid?

You might want to give this one a try:

isset Manual

or you can actually show the controller code in which you're failing to set the errors to the View object (probably inside of a condition).

An undefined variable means it does not exists. You can just wrap it inside isset() to do what you want to do:

<?php if( isset( $errors ) ): ?>

Isset is one of the few language constructs that work on unset variables without giving a warning / error. Another one is empty().

PHP is throwing an error because the error reporting includes the E_STRICT constant, which throws an exception if an undefined variable is pointed to.

Use isset() instead - It's good practice to check if your variable even exists (if there's a chance that it doesn't).

As Kemo said you should use isset. What you are actually doing there is checking if the variable $errors has a value that evaluates to true/false. The non-existence of the variable does not equate to false and you wouldn't want it to, you want spelling mistakes etc... to throw errors rather than any variable just being considered null regardless of whether it's actually been declared. isset is specifically designed to check for the existence of the variable. As you still want to check if it also evaluates to true you should be doing:

if(isset($errors) && $errors)