I transformed the choice within the Joomla configuration section to exhibit all errors (E_ALL) and my component is essentially useless.

For example, inside a view (editapp) I've got a template, default.php, which consists of such things as:

    <input class="text_area" type="text" name="application_name" id="application_name" size="50" maxlength="250" value="<?php echo $item->application_name" ?> />

Now due to $item->application_name after i run this the very first time (a brand new record), you will see notice errors everywhere Trying to get property of non-object

The reason being exactly the same template can be used to save and editing. I adopted lessons plus they appeared to get it done by doing this.

What's the click here with PHP development. Must I be checking this stuff? if(isset($item-)) , what's the best practice for PHP development?

To be sure using the others - choose no errors. Actually, I would recommend going beyond E_ALL and including E_STRICT, that is the way i do my development. You will find reasons for every of individuals notices, and you will prosper to get rid of them. The most known reason would be that the notices typically explain small bugs that makes it harder to locate and connect bigger bugs in the future. It isn't too not the same as the thought of using statements: they assist you squish bugs as rapidly as you possibly can.

Regarding your particular example, instead of using isset() before referencing it, I suggest initializing the item to some sane base condition starting the page (possibly using isset() at that time). For instance, you may set the applying_title value for an empty string. This will allow you and also hardwearing . output statement nice clean but correctly address the notice by looking into making sure the variable is initialized before utilizing it. (FWIW, in lots of languages, using unitialized variables causes a much more aggressive response as a compile-time error.)

It's absolutely worth eliminating the errors and alerts inside your code a couple of reasons:

  • Every error will get written towards the error log. If they are irrelevant, you've polluted your error log with information that's by no means useful.
  • Most alerts are suggestive of bigger errors. The unset variable you are referencing may cause problems in the future in situations you might not have believed of.
  • Other people who are utilizing your template might not have the power or understanding to show off errors, leading to them not making use of your code.