Basic PHP/ASP Functions Comparison

Ahmed August 19, 2010 5

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 =
;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(“Website name is: ” & name)
Increment $variable++;
No Fuction Available

Perform Manually:
For var = 1 to 10
Decrement $variable–;
As above
If Statement if (condition) {
} elseif (condition) {
If condition Then

condition Then

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
For Loop for (initialization; condition; increment) {
code to execute

For index = 1 to 10
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 {

Class ClassName

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’);
The Virtual Keyword
Use the virtual keyword to indicate a path beginning with a virtual directory:
<!– #include virtual =”/html/” –>

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\” –>

Require file require(‘file.php’);
MySQL connect mysql_connect(); Set var1 = Server.CreateObject(“ADODB.Connection”)
Set var2 = Server.CreateObject(“
.Recordset”)var1.Open “DSN=name
MySQL query mysql_query(); Set rs = var1.Execute(strSQL)
Do while not rs.eof


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.


  1. SEO Manchester August 23, 2010 at 11:26 - Reply

    I wish I had seen this before.

  2. Rob Bromilow August 23, 2010 at 12:25 - Reply

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

  3. SEO Manchester August 23, 2010 at 12:26 - Reply

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

  4. Anders Hesselbom August 29, 2010 at 09:19 - Reply

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

    • Ahmed August 29, 2010 at 15:47 - Reply

      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 Response »

Listing all pages