Forum Moderators: open
Ok now the code...I know a little bit of PHP. I learn by actually using code I learn as I have to get use to it. Well I have a lot of repetive code on my site and so naturally with PHP all I wanted to do was to put all that code in a single spot to call it from when needed.
1.) Includes - Calls a file where all my HTML code is located.
2.) Variables - Instead of putting the HTML over and over again I can just set it to a variable to be called from when I need it on the pages. My $vars are located in the includes.php/asp file.
3.) Print - Simply prints out the HTML code from the variable.
Here is my PHP code and from what the teacher subscribes to as AP (not sure he understands what I'm trying to do).
PHP
***index.php***
<?php
include("/public_html/themes/includes.php");***(includes.php)***
$variable = '<span class="text">text</span>';***index.php***
print $variable;
?>
ASP
***index.asp***
<%
<!--#include file = "/public_html/themes/includes.asp"-->
%>***includes.asp***
<%
$variable='<span class="text">text</span>'
%>***index.asp***
<%
response.write($variable)
%>
So right now I'm trying to figure out if this code is correct and should work in ASP as I know it would in PHP.
Looking forward to learning and knowing both ASP and PHP!
John
Final code....
index.asp
<%
<!--#include file = "includes.asp"-->
response.write(testme)
%>
includes.asp
<%
testme="<span class=""test"">text</span>"
%>
It's different in that the includes can not be inside the ASP syntax (odd but ok). Double quotes are escaped by sending two double quotes.
What about single quotes?
Thanks again EC
John
<%@ Page Language = "vbscript" %>
<%
Response.execute(/public_html/themes/includes.asp)
variable = "<span class=""text"">text</span>"
Response.write(variable)
%>
Note that you should really place the following line before using the variable...
Dim variable
This will produce more efficent code.
If you're used to PHP, I'd take a look at using PerlScript rather than VB in your ASP pages, you'll find it easier.
Response.execute("/public_html/themes/includes.asp")
It's different in that the includes can not be inside the ASP syntax (odd but ok).
Easy_Coder used SSI, It's server dependent (nothing to do with ASP) and it can be used in PHP as well as with ASP on most web servers, but its functionality is slightly different.
Double quotes are escaped by sending two double quotes.
Yes, in VBScript you escape quotes by using two double quotes. If you are using another language in your ASP pages it will be different (you can escape quotes in the same was as PHP if you use PerlScript instead of VBScript)
What about single quotes?
There's no need to escape single quotes in VBScript.