PHP to ASP Code Convertor

Converting PHP to ASPNEED TO CONVERT your PHP code to ASP? Or maybe are you a PHP programmer who wants to learn ASP?

Well, you can Just paste your PHP code into the textbox at ME-U.com, press the CONVERT PHP TO ASP button, and voila! You’ve got ASP.

Well, pretty much. It was built at the end of a very large project, when the programmer’s client said, “Oh, did I say PHP? I meant ASP”. So, only the functions needed for that particular project were included.

It’s not perfect, but if you need a down-and-dirty quick convert, this just might do the trick for you. The results will let you know if there is something it can’t deal with.

We converted this page from a WordPress theme.
(Page width is limited here)

<?php
/*
Template Name: Sitemap
*/
?>

<?php get_header(); ?>

<div id=”content_box”>
<div id=”content” class=”pages”>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>    <div class=”entry”>      <p><strong><a href=”<?php bloginfo(‘url’); ?>” alt=”<?php bloginfo(‘name’); ?>”>Home</a></strong></p>
<h3>All internal pages:</h3>
<ul>
<?php wp_list_pages(‘title_li=’); ?>
</ul>
<h3>All internal blog posts:</h3>
<ul>
<?php $archive_query = new WP_Query(‘showposts=1000’);
while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a> <strong><?php comments_number(‘0’, ‘1’, ‘%’); ?></strong></li>
<?php endwhile; ?>
</ul>
<h3>Monthly archive pages:</h3>
<ul>
<?php wp_get_archives(‘type=monthly’); ?>
</ul>
<h3>Topical archive pages:</h3>
<ul>
<?php wp_list_categories(‘title_li=0’); ?>
</ul>
<h3>Available RSS Feeds:</h3>
<ul>
<li><a href=”<?php bloginfo(‘rdf_url’); ?>” alt=”RDF/RSS 1.0 feed”><acronym title=”Resource Description Framework”>RDF</acronym>/<acronym title=”Really Simple Syndication”>RSS</acronym> 1.0 feed</a></li>
<li><a href=”<?php bloginfo(‘rss_url’); ?>” alt=”RSS 0.92 feed”><acronym title=”Really Simple Syndication”>RSS</acronym> 0.92 feed</a></li>
<li><a href=”<?php bloginfo(‘rss2_url’); ?>” alt=”RSS 2.0 feed”><acronym title=”Really Simple Syndication”>RSS</acronym> 2.0 feed</a></li>
<li><a href=”<?php bloginfo(‘atom_url’); ?>” alt=”Atom feed”>Atom feed</a></li>
</ul>
</div>
<div class=”clear rule”></div>
<?php endwhile; endif; ?>

</div>

<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>

Here are the results. First, the errors – the program lets you know exactly what it didn’t understand:

….

Couldn’t translate these functions:
php
/
*
Template
Name:
Sitemap
*
/
php
get_header(
)
;
php
php
the_title(
)
;
php
bloginfo(

url’
)
;
php
bloginfo(

name’
)
;
php
wp_list_pages(

title_li=

)
;
php
php
the_permalink(
)
php
the_title(
)
;
php
the_title(
)
;
php
comments_number(

0

,

1

,

%

)
;
php
endwhile;
php
wp_get_archives(

type=
monthly’
)
;
php
wp_list_categories(

title_li=
0

)
;
php
bloginfo(

rdf_url’
)
;
php
bloginfo(

rss_url’
)
;
php
bloginfo(

rss2
_url’
)
;
php
bloginfo(

atom_url’
)
;
php
endwhile;
endif;
php
get_sidebar(
)
;
php
get_footer(
)
;

And then the converted ASP code.
(Please realize that there is only so much width for this post.)

The ASP equivalent of your PHP:

<%
Dim gv_archive_query

php
/*Template Name:Sitemap
*/
%>

<%
php get_header();
%>

<div id=”content_box”>

<div id=”content” class=”pages”>

<%
php If have_posts() then

: Do While have_posts()

: the_post();

Loop

End If

%>

<h2><%
php the_title();
%></h2>
<div class=”entry”>
<p><strong><a href=”<%
php bloginfo(‘url’);
%>” alt=”<%
php bloginfo(‘name’);
%>”>Home</a></strong></p>
<h3>All internal pages:</h3>
<ul>
<%
php wp_list_pages(‘title_li=’);
%>
</ul>
<h3>All internal blog posts:</h3>
<ul>
<%
php gv_archive_query = new WP_Query(“showposts=1000″)
Do While gv_archive_query->have_posts()

: gv_archive_query->the_post();

Loop

%>
<li><a href=”<%
php the_permalink()
%>” rel=”bookmark” title=”Permanent Link to <%
php the_title();
%>”><%
php the_title();
%></a> <strong><%
php comments_number(‘0′,’1′,’%’);
%></strong></li>
<%
php endwhile;
%>
</ul>
<h3>Monthly archive pages:</h3>
<ul>
<%
php wp_get_archives(‘type=monthly’);
%>
</ul>
<h3>Topical archive pages:</h3>
<ul>
<%
php wp_list_categories(‘title_li=0’);
%>
</ul>
<h3>Available RSS Feeds:</h3>
<ul>
<li><a href=”<%
php bloginfo(‘rdf_url’);
%>” alt=”RDF/RSS 1.0 feed”><acronym title=”Resource Description Framework”>RDF</acronym>/<acronym title=”Really Simple Syndication”>RSS</acronym> 1.0 feed</a></li>
<li><a href=”<%
php bloginfo(‘rss_url’);
%>” alt=”RSS 0.92 feed”><acronym title=”Really Simple Syndication”>RSS</acronym> 0.92 feed</a></li>
<li><a href=”<%
php bloginfo(‘rss2_url’);
%>” alt=”RSS 2.0 feed”><acronym title=”Really Simple Syndication”>RSS</acronym> 2.0 feed</a></li>
<li><a href=”<%
php bloginfo(‘atom_url’);
%>” alt=”Atom feed”>Atom feed</a></li>
</ul>
</div>
<div class=”clear rule”></div>

<%
php endwhile;endif;
%>

</div>

<%
php get_sidebar();
%>

</div>

<%
php get_footer();
%>

Please Note this is a development version and contains the following errors:

Function names do not have the fn_ prefix added when they are called (see notes)
MySQL / SQL commands are not yet translated properly.

The source code for the converter is also available to use, with just a couple of stipulations. There is a comparison of ASP vs. PHP features.  And a list of the converter’s issues – what it can and can’t do.

Did I mention that the PHP to ASP Convertor is free?

POLL

[poll id=”2″]

Leave a Reply