Thursday, June 4, 2009

Advantages of php over asp and converting asp site into php site.

php is having many advantages over asp in terms of cost, Speed, Security and flexibility.

Refer below articles comparing asp and php.

So, it will be useful if we convert any existing asp websites into php site.

Some converters are available to convert any asp website into php site.

You can download asp2php converter here. I haven't tried it yet.

Some online converters are also available to convert asp webpage into php pages.

Find below an online converter.

If you want to manually convert the asp pages into php pages, you can follow below steps.

Conversion of asp to php.

In asp no need to put semicolon at the end of the each line, but semicolon required in php.
1. xml syntax used in php version 4

replaced by,

replaced by,

replaced by,

replaced by,

DescriptionText =(DescriptionNode.text)
replaced by,
$DescriptionText =($DescriptionNode->get_content())

2. asp syntax and php syntax

1. dim DescriptionText
replaced by,
$ DescriptionText;

2. CStr(Request("section"))
replaced by,

3. if isnull(SectionID) or trim(SectionID) = "" then

end if
replaced by,
if($SectionID=="Null" || trim($SectionID)== "")

4. XMLFileName = BaseXMLPath & "about/" & SectionID & ".xml"
Replaced by,
$XMLFileName = $BaseXMLPath."about/".$SectionID.".xml";

5. XMLLocalFileName = Server.MapPath(XMLFileName)
In asp Server.MapPath() function returns the physical location of the file name of asp file.
It return something like this c:/apache/htdocs/foldername/filename.asp
We can use below workaround to get file location.

Now the ‘$XMLLocalFileName’ return c:/apache/htdocs/foldername/filename.php
Anyway, if you know alternate simple solution you can share it here.

6. In asp the logical operators used in conditions like this
&&-‘and’ ||- ‘or’

But in php it is replaced by && and ||

7. In asp the array declaration is like this

But in php it is replaced by array()

8. The asp Request.ServerVariables("URL") function return folder name and filename.
In php its equivalent function is $_SERVER['PHP_SELF'];

9. In asp the function format is

function functionName(argument)
//body of function
end function
but in php function format is
function fuctionName(argument)
//body of function
10. In asp the for loop format is

for i=0 to sectionNode.length
//body of for loop
but in php its equivalent is,

//body of for loop

11. In asp Response.Write() function is used to display content in webpage and Response.End() is used to end the execution flow.

Its equivalent function used in php is echo and die.

12. In asp Request.ServerVariables("HTTP_HOST") return the server name

Its equivalent function used in php is $_SERVER['HTTP_HOST']

13. the Request.Form() and Request.QueryString in asp is same as $GET[‘’] and $_POST[‘’] in php

14. the instr() function return the integer value of find string in asp, its equivalent function used in php is strpos()

15. the Int() function in asp is replaced by intval() in php.

16.the Rnd() function in asp is replaced by rand() in php

17. the Len() function in asp is replaced by strlen() in php

18.The Mid() function in asp returns a specified number of characters from a string, we used substr() function to return the same string in php.

19. the Replace() function in asp is replaced by str_replace() in php .

20. the Trim() function in asp is replaced by trim() in php.

More Articles...

No comments:

Search This Blog