几种编程语言的注释方法

一、HTML语言

index.html
<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Document</title>
	</head>
	<body>
		<p>HTML语言如何注释>/p><!--HTML注释文字-->
	</body>
</html>

二、CSS样式

styles.css
.spostinfo ul li{line-height:24px;}/*转载注明样式*/
.backs {cursor: pointer;}/*站外引用trackback*/

三、ASP语言

asp.asp
<%
	classid1=rs("classid")
	sql="select  top 3 * from news where classid="&classid1&" order by time desc "
	set rs1=conn.execute(sql)  'ASP注释的样式
	do while not rs1.eof
%>

四、PHP语言

index.php
$arr_ok = str_replace('"','',$arr_ok);//用C++风格注释PHP
$arr_ok = str_replace("\n", "", str_replace(" ", "", $arr_ok));
/*
 用C风格注释PHP
*/
$arr_ok = str_replace("\t","",$arr_ok); 
<!--用XML风格注释PHP-->
$arr_ok = str_replace("\r\n","",$arr_ok); 

五、Javascript语言

app.js
/*
方法一:C风格注释JS
*/
var xmlHttpObject;
try { 
		xmlHttpObject=new ActiveXObject("Microsoft.XMLHTTP"); 
	}
catch (e) {
	try {
		xmlHttpObject=new XMLHttpRequest();  //方法二:C++风格注释JS
	}
	catch (e) {
		xmlHttpObject=false;  
	}
}

六、C语言

main.c
#include <conio.h>
#include <string.h>
#include <stdio.h>
int main( int argc, char ** argv )
{
    char *s1="Hello, Programmers!";  //单行C注释文字
    char *s2="aello, programmers!";
    int r;
	/**
	 *	多行C注释文字
	 */
    r=memcmp(s1,s2,strlen(s1));
    printf("%d\n",r);
    return 0;
}

7.C#语言

csharp.csharp
namespace Functions 
{ 
	public class Factorial 
	{ 
		public static int Calc(int i)   <!--C#的注释文字--> 
		{ 
			return((i <= 1) ? 1 : (i * Calc(i-1)));   //单行C#注释文字
		}
		/**
		 * 多行C#注释文字
		 */		
	}
}

评论

评论加载中…