What is the reason for using Option Explicit in ASP? In other words I want to know the usage of Option Explicit in ASP.
What is the reason for using Option Explicit in ASP? In other words I want to know the usage of Option Explicit in ASP.
HiOriginally Posted by timmy
The Importance of Option Explicit in ASP is to avoid the usage of misSpelling variables .
For ex:
<%
sEmpID = request.form("TxtEmpID")
sEmpName = request.form("TxtEmpName")
response.write "Login ID : "&sEmpId &" Login Name "&sEpName
%>
Notice the misSpelling of sEmpName ,bcoz server automatically create a new variable (sEpName) with blank string and since we have not used Option Explicit , this error goes un-noticed.
When u use Option Explicit it must be the first line of ASP Script
<%
Option Explicit
dim sEmpId,sEmpName
sEmpID = request.form("TxtEmpID")
sEmpName = request.form("TxtEmpName")
response.write "Login ID : "&sEmpId &" Login Name "&sEpName
%>
In this case u got an Error like Variable is Undefined : sEpName.
This let's us know exactly where the error is, so we can go straight to the problem and fix it.
Santhi