CFF KB - Carrz-Fox-Fire Promotions Knowledge Base
CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.Knowledge Base
- Breadrumbs:
Convert PHP to ASP Classic - Special Characters pt.2 (Facebook Comment Time Sent)
- Article ID:
126 - Date Created
Monday, March 28, 2011 - Last Updated
Monday, March 28, 2011 - This Article Has been Viewed
2459 times - Short Desc
The articles here are to help people convert PHP scripting language over to ASP Classic. - Details
This article will focus on the different Characters that PHP uses and what the equivalent is in ASP Classic and how to re-write the code to work in your ASP Classic projects.
Be sure to look at the bottom for the Related articles, so you can continue in these lessons on learning the process. - Recreate Issue
To recreate this issue:
<?php
if($days2 > 0)
echo date('F d Y', $rows['date_created']);
elseif($days2 == 0 && $hours == 0 && $minutes == 0)
echo "few seconds ago";
elseif($days2 == 0 && $hours == 0)
echo $minutes.' minutes ago';
else
echo "few seconds ago";
?>
Same as in the previous article.
$ = sign is for Variables
& = is to seperate the Variables from the next variable.
echo = Writes out the information to the page. - Resolve Issue
To resolve this issue:
<%
if(days2 > 0) then
GDP = DateDiff("d", getdate, rsProCom("comdate"))
response.Write "posted: "&GDP&" days ago"
elseif(days2 = 0 & hours = 0 & minutes = 0)then
response.Write "few seconds ago"
elseif(days2 = 0 & hours = 0)then
response.Write "minutes.' minutes ago'"
else
response.Write "few seconds ago"
end if
%>
Looking at the above code.
In ASP Classic when we have an IF Statement, we also use a THEN.
This creates what is called an IF THEN Statement.
Unlike PHP where it using only the IF and not the THEN, we do here.
Lets look at the changes between the 2 codes and how to use them.
#1:
In PHP the display of a database record is presented with the following
$rows['date_created']
In Classic ASP, we use this<%
rsProCom("comdate")
%>
#2:
echo gets replaces with the ASP Classic Equivalent:
Response.Write
Now, there are several different ways to write this out.
Response.write("Your Information goes here")
(or)
Response.write"Your Information goes here"
We are using the 2nd in this example as well as nearly 99% of all articles written here on CFF KB.
#3: Date
PHP uses the date('F d Y') to get the data format of: March 28, 2011
ASP Classic, we are going to get it as: 3/28/2011
Same thing, but instead of writing the date out, we are gets its numbers seperated by the /
#4:
($days2 == 0 && $hours == 0 && $minutes == 0)
In the above, for ASP Classic, we do not need the $ and only need a single = and & symbols.
Which results in the following
(days2 = 0 & hours = 0 & minutes = 0)
The & seperates are variables so that we can extend the elseif statement to continue on.
#5:
The ending ; semicolon
In ASP Classic, this is not needed in this routine, though it is used in some area's, it is not used here.
#6:
The ending END IF
In PHP there is no END IF.
In ASP Classic, we use the END IF, to stop our IF THEN Statement from running off the map.
--------
Related Articles
Convert PHP to ASP Classic - Special Characters pt.1 (Facebook Comment Time Sent)«
Share With Friends (Updated 6-8-2010)
Recent Articles
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 24695
- Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. 21297
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 19544
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 17785
- The backup set holds a backup of a database other than the existing 16826