Its not really a valid comparison. PHP is better than old-school ASP, but ASP.NET is an enterprise-capable framework for distributed applications. Its competitor is J2EE, not PHP so much. I can see why you would like PHP over ASP.NET, but there are some killer development tools available for .NET. For the last few years I've been working on a product in VB that uses ASP as the presentation layer. The improvements in .NET are unreal, but ASP still has a place for simple web sites.
Heres an implementation of echo for ASP:
Code:
<%@ Language=VBScript %>
<SCRIPT LANGUAGE="Javascript" RUNAT="SERVER">
var ECHO_TOKEN = '%d';
//-------------------------------------------------------------------------
// FUNCTION: echo
// PURPOSE: Writes a message to the Response stream that contains
// embedded data elements to avoid concatenation.
// ARGUMENTS: text - message string to output. embedded tokens
// will be replaced by the non-formal arguments
// passed to the function at runtime, in order.
//-------------------------------------------------------------------------
function echo(text)
{
_echoHelper(text, ECHO_TOKEN, echo.arguments);
return;
}
//-------------------------------------------------------------------------
// FUNCTION: echobr
// PURPOSE: Writes a message to the Response stream that contains
// embedded data elements to avoid concatenation, with an
// extra break tag at the end.
// ARGUMENTS: text - message string to output. embedded tokens
// will be replaced by the non-formal arguments
// passed to the function at runtime, in order.
//-------------------------------------------------------------------------
function echobr(text)
{
_echoHelper(text, ECHO_TOKEN, echobr.arguments);
Response.Write('<BR>');
return;
}
//-------------------------------------------------------------------------
// FUNCTION: _echoHelper
// PURPOSE: Parses a string and replaces token values with elements
// in the args array in order. Index 0 of the array is not
// included. Performs operation without concatenations.
// ARGUMENTS: text - message string to output. embedded tokens
// will be replaced by the non-formal arguments
// passed to the function at runtime, in order.
// token - replacable string
// args - array of values to insert into text
//-------------------------------------------------------------------------
function _echoHelper(text, token, args)
{
var start = 0;
var finish;
var i;
for (i=1; i<args.length; i++)
{
finish = text.indexOf(token, start);
if (finish >= 0)
{
Response.Write(text.substring(start, finish));
Response.Write(args[i]);
finish = finish + 2;
start = finish;
}
}
Response.Write(text.substring(start, text.length));
return;
}
</SCRIPT>
<HTML>
<HEAD>
</HEAD>
<BODY>
<% dim ip: ip = Request.ServerVariables("REMOTE_ADDR")
echo "This page was requested on %d from IP %d at %d", Date(), ip, Time()
%>
</BODY>
</HTML>