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.
  • Breadrumbs:
  • Convert PHP to ASP Classic - Special Characters pt.2 (Facebook Comment Time Sent)

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • 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)«