tags:

views:

78

answers:

3

I saw this post:

"Typos… Just use option strict and explicit please.. during one software development project, which I was on as a consultant, they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spell and would declare variables with incorrect spelling.. no big deal, until you use the correct spelling when you’re assigning a value to it… and you had option explicit off. Ouch to them…"

what is an option strict and explicit anyway? I have googled it up but can't get the idea (because mostly it's Visual Basic, I'm doing PHP)

+1  A: 

Find details here: http://support.microsoft.com/kb/311329

The Option Explicit statement

By default, the Visual Basic .NET or Visual Basic compiler enforces explicit variable declaration, which requires that you declare every variable before you use it. To change this default behavior, see the Change the Default Project Values section.

The Option Strict statement

By default, the Visual Basic .NET or Visual Basic compiler does not enforce strict data typing. To change this default behavior, see the Change the Default Project Values section.

danben
+4  A: 

Option Explicit means that all variables must be declared. See here. Without this, you can accidentally declare a new variable just by misspelling another variable name. This is one of those things that cause a lot of grief as you're trying to debug VB programs and figure out why your program isn't working properly. In my opinion, this shouldn't even be an option - it should always be on.

Option Strict "restricts implicit data type conversions to only widening conversions". See here. With this option enabled, you can't accidentally convert one data type to another that is less precise (e.g. from an Integer to a Byte). Again, an option that should be turned on by default.

TLiebe
any equivalent in php?
Ygam
A: 

In PHP it usually a very good idea to set error_reporting to E_ALL on your development machine, and treat any E_NOTICE's as errors.

MGriesbach
will this make me do in php what option strict do in VB? how?
Ygam