RSS Feed Icon
Twitter Icon
Twitter Icon
Delicious Icon

Basic PHP/ASP Functions Comparison

Basic PHP/ASP Functions Comparison

PHP and ASP are amongst the most widely used programming languages online and generally just knowing one will get you by all the way.

There are some people however, who would like to know both for various reasons I won’t bore you with but this list will eb a great starting point for anyone who wished to do so.

NOTE: By ASP, I mean ASP (VB), not ASP (C) or ASPX

Basic PHP/ASP Function Comparison

Opening and
Closing Tags
<?PHP … ?> <% … %>
Write to Browser echo “Hello World!”; response.write(”Hello World!”)
Inline Comment // This is a comment
# This is a comment
‘ This is a comment
Comment Block /*
This is a Comment Block
*/
/*
This is a Comment Block
*/
Declare a varialble $var_name = value;
$number = 16;
dim var_name
var_name = “value”
Concatination $var1 = value-1;
$var2 =
value-2
;

echo $var-1 . $var-2;

Dim var1, var2, var3
var1 = “Hello”
var2 = ” Worlds”
var3 = var1 & var2
Call a Variable $txt = “Hello World”;
echo $txt;
dim name
name=”Web Designer Online”
response.write(name)
or
response.write(”Website name is: ” & name)
Increment $variable++;
++$variable;
No Fuction Available

Perform Manually:
<%
For var = 1 to 10
…code…
Next
%>
Decrement $variable–;
–$variable;
As above
If Statement if (condition) {
//
code
} elseif (condition) {
//code
}else{
//
code
}
If condition Then
code

ElseIf
condition Then
code

Else
code
End If
I sequal to if ($var1==$var2) {
// do something

}
If var1 = var2 Then
do something

End If
AND if ($var1==$var2 && $var1==$var3) {
// do something

}
If var1 = var2 And var3 = var4 Then
do something

End If
OR if ($var1==$var2 || $var1==$var3) {
// do something

}
If var1 = var2 Or var3 = var4 Then
do something

End If
NOT if (!$var1) {
// do something

}
If var1 = var2 Not var3 = var4 Then
do something

End If
While Loop while (condition)
//
code to be executed
Do While condition
code to be executed
Loop
For Loop for (initialization; condition; increment) {
//
code to execute

}
For index = 1 to 10
Response.Write(index)
Next
Array $arr = array();
$arr = array(1,2,3,4);
$arr = array(’one’=>1);
Dim myFixedArray(3) ‘Fixed size array
Dim myDynArray() ‘Dynamic size array
Array Add item $arr[] = 1;
$arr['key'] = 1;
Dim myFixedArray(3) ‘Fixed size array
myFixedArray(0) = “Zero”
myFixedArray(1) = “One”
myFixedArray(2) = “Two”
myFixedArray(3) = “Three”
Functions function func() {
// do stuff

}
function func() {
do stuff

}
Class class ClassName {
//
code

}
Class ClassName
code

End Class
GET requests $var = $_GET;
$var = $_GET['variable'];
Dim name
name = Request.QueryString(”")
POST requests $var = $_POST;
$var = $_POST['variable'];
Dim name
name = Request.Form(”")
Date Function date(); Response.Write(Date())
Include file include(’file.php’);
include_once(’file.php’);
The Virtual Keyword
Use the virtual keyword to indicate a path beginning with a virtual directory:

<!– #include virtual =”/html/header.inc” –>

The File Keyword
Use the file keyword to indicate a relative path. A relative path begins with the directory that contains the including file.

<!– #include file =”headers\header.inc” –>

Require file require(’file.php’);
require_once(’file.php’);
n/a
MySQL connect mysql_connect(); Set var1 = Server.CreateObject(”ADODB.Connection”)
Set var2 = Server.CreateObject(”
ADODB
.Recordset”)

var1.Open “DSN=name

MySQL query mysql_query(); Set rs = var1.Execute(strSQL)
Do while not rs.eof

Conclusion

It’s always good to know the basic syntax of a variety of languages in your field just to get you by those odd task’s that appear once in a while.

Enjoy this post? Please share!

  • DZone
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • Google Bookmarks
  • Facebook
  • Sphinn

5 Responses to “ Basic PHP/ASP Functions Comparison ”

  1. I wish I had seen this before.

  2. Rob Bromilow says:

    I have seen this before, Dave Stopher SEO. I would have thought you would have too.

  3. This is great. I work on ASP sites now and again; this is a brilliant reference for me and others.

  4. ASP 3 is ten years old and discontinued. Odd choice for comparison.

    • Ahmed says:

      Thanks for the feedback Anders. It’s actually been quite some time since I put this list together and thought it would make a good blog post and may be useful to some out there!

Leave a Reply