I am developing an application and want to display a form that will be filled in if editing the form, but will not be if the form will be a new entry. I believe the least verbose way of doing this is to have just one form and to suppress any errors for echoing my variables so that nothing will be printed if it is a new form (since the variables will not exist if it is a new form). For example:
<?php
if ( ! $new_item) {
$variable = 'Example';
}
?>
<form>
<input type="text" name="inputbox" value="<?php echo @$variable; ?>" />
</form>
Is this a good practice, or is there a better way of doing it? Should I make separate views for the new items and for the items to be edited? What are the performance repercussions of doing this?