I have a simple .shtml
file that I have declared a variable in it.
<!--#set var="testVar" value="12345" -->
But when I want to print the value using
<!--#echo var="testVar" -->
it says
Variable 'testVar' cannot be found
What's the problem? I'm using IIS 7.5 and I also tested in on Apache2 but it's not working either!
This works fine for me:
<!--#set var="testVar" value="12345" -->
<!--#echo var="testVar" -->
Do you have Apache configured correctly? You may need to turn on mod_include. The following code should output the date once configured properly:
<!--#echo var="DATE_LOCAL" -->
I had the same issue. In my case, I was setting a variable in the main file, and trying to read it in an included template.
The solution was to to place the <!--#set
after the <!DOCTYPE
declaration.
IIS doesn't support your code.
<!--#set var="testVar" value="12345" -->
IIS doesn't support #set that is why it responds. "Variable 'testVar' cannot be found", because it has never been created.
Windows server and Apache server has the same module name (SSI) and they use the same syntax. BUT! Apache server supports #set and other commands like #if #else etc which windows server doesn't. So the confusion is complete.
For a list of commands you can use in IIS: MSDN blog about SSI on IIS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With