Convert PHP to ASP
PHP vs ASP
Feedback / Contact us
Welcome to the one and only PHP to ASP convertor. It was originally
built when, towards the end of a large project, a client mentioned in
passing that when they said PHP, what they actually meant was
The result as it stands only contains (most of) the functions necessary
for that one project. It is not yet complete, but it will still convert
large parts of pages written in PHP into ASP (VB), but will need some
hand tweeking to finish the job. Nevertheless, it will certainly save
you a lot of time if you are intending to migrate from PHP to ASP.
What it will convert:
- PHP syntax to VB syntax, including strings, and magic quotes.
- Functions between <?
...?> tags. Everything outside the tags will be left alone,
as will comments.
- Variable and function names. To avoid using ASP (VB) keywords, and
to avoid conflicts with variables and functions, variables and functions
are renamed as follows:
- Global variables have the prefix gv_
- Local variables have the prefix lv_
- Functions have the prefix
- A few function specicific tweaks are added, for example the php's
str_pos is zero based.
ASP's equivalent (InStr)
is 1 based, so the replaced function is InStr(....)-1.
- Multiline comments are removed and replaced with '
multiline comment removed . This is because multiline comments
are normally only marking chunks of redundant code. Single line comments
- MySQL calls are replaced with microsoft SQL over ADODB
The wider range of functions in PHP also means that some functions
have had to be written in ASP, which means it will be slower than the
PHP equivalent (though probably not noticably in most cases.). ASP and
PHP are very different languages, and from my experience, it certainly
seems that PHP offers the most flexibility. This is, of course a problem
for conversion, and so far, the following issues are unresolved:
- Types. PHP lets you access variables very freely. Numbers and strings,
for example can be treated as Boolean; Strings can be accessed as
arrays, etc, etc. ASP does not let you do any of this, and the convertor
does not make any allowance for it either. If your code contains such
issues, you will get errors when you run the ASP code that the converter
- ASP does not support associative arrays. (Arrays with string keys.)
Again if your code contains such things, you will get errors when
you run your page.
- Cookies, and variables passed with either GET or POST are simply
available as variables for the next page in PHP; in ASP they are not.
You have to add your own code to get these variables.
- Large page (over 40k or so) may time out - split the page in half
at an appropriate point to work around this.
- PHP's special escaped characters (like '\\r\\n'
for a new line). You need to use ascii equivalents, (ie chr(10)
& chr(13) ).
- Functions not in its repetoire will be left in their original form.
Other than that, the other issues are mainly just that I haven't had
time to include all the functions and language features yet. Most lesser
used functions, and some important language features, such as classes
are not yet available.
Remember, this connection is not secure, so you may want to remove
any usernames or passwords from your pages
There is much further work to be done on this convertor, and you can
help by either donating or editing the source or function list. Click
here to download it.