I am in the process of creating an associative array called errMsgs[]
that will hold error messages that correspond to a particular <input>
field error. Which form of testing errMsgs[]
is more correct, faster, and safer? Does either method have important advantages or disadvantages?
Contact Form Code Snippet: Focus --> The third <td></td>
in a table with three columns as in ...
(column1) (column2) (column3) <----Focus of this code snippet.
--------- ---------- ----------
Where column1 is a <label></label>
inside of a <td></td>
.
Where column2 is an <input />
control inside of a <td></td>
.
Where column3 is an empty <td></td>
, filled conditionally based on the errMsgs[]
associative array.
Skeleton 1
<tr>
<td>
<label>
</label>
</td>
<td>
<input />
</td>
<td>
<?php
if($errMsgs['firstName'])
{
echo $errMsgs['firstName']; //This element is not from user input.
}
?>
</td>
</tr>
Skeleton 2
<tr>
<td>
<label>
</label>
</td>
<td>
<input />
</td>
<td>
<?php
if(isset($errMsgs['firstName']))
{
echo $errMsgs['firstName']; //This element is not from user input.
}
?>
</td>
</tr>
Escaping and coding style issues aside, which skeleton is superior? Which have you used in the past? I want to use the best way.