Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSI #set variable and #echo issue

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!

like image 284
David Weng Avatar asked Nov 02 '10 10:11

David Weng


3 Answers

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" -->
like image 129
Craig Myles Avatar answered Jan 04 '23 08:01

Craig Myles


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.

like image 27
trey-jones Avatar answered Jan 04 '23 07:01

trey-jones


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

like image 39
frank jelstrup Avatar answered Jan 04 '23 07:01

frank jelstrup