TypeCodes

几种编程语言的注释方法

1 HTML语言
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <p>HTML语言如何注释>/p><!--HTML注释文字-->
    </body>
</html>
2 CSS样式
1
2
.spostinfo ul li{line-height:24px;}/*转载注明样式*/
.backs {cursor: pointer;}/*站外引用trackback*/
3 ASP语言
1
2
3
4
5
6
<%
    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
%>
4 PHP语言
1
2
3
4
5
6
7
8
$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);
5 Javascript语言
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
/*
方法一:C风格注释JS
*/
var xmlHttpObject;
try { 
        xmlHttpObject=new ActiveXObject("Microsoft.XMLHTTP"); 
    }
catch (e) {
    try {
        xmlHttpObject=new XMLHttpRequest();  //方法二:C++风格注释JS
    }
    catch (e) {
        xmlHttpObject=false;  
    }
}
6 C语言
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#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#语言
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
namespace Functions 
{ 
    public class Factorial 
    { 
        public static int Calc(int i)   <!--C#的注释文字--> 
        { 
            return((i <= 1) ? 1 : (i * Calc(i-1)));   //单行C#注释文字
        }
        /**
         * 多行C#注释文字
         */     
    }
}

Comments »