测试语法高亮
highflybird
- 登录 发表评论
这个是一个测试页面,测试编程语言在drupal上的表现。
结果还是不如人意,没有wordpress上表现那么好。
PHP语言:
<?php
/* 尝试MySQL服务器连接。 假设您正在运行MySQL
具有默认设置的服务器(用户“ root”,无密码) */
$link = mysqli_connect("localhost", "root", "", "demo");
//检查连接
if($link === false){
die("错误:无法连接。 " . mysqli_connect_error());
}
if(isset($_REQUEST["term"])){
//预处理select语句
$sql = "SELECT * FROM countries WHERE name LIKE ?";
if($stmt = mysqli_prepare($link, $sql)){
//将变量作为参数绑定到预处理语句
mysqli_stmt_bind_param($stmt, "s", $param_term);
//设置参数
$param_term = $_REQUEST["term"] . '%';
// Attempt to执行预处理语句
if(mysqli_stmt_execute($stmt)){
$result = mysqli_stmt_get_result($stmt);
//检查结果集中的行数
if(mysqli_num_rows($result) > 0){
//获取结果行作为关联数组
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<p>" . $row["name"] . "</p>";
}
} else{
echo "<p>没有找到匹配的记录</p>";
}
} else{
echo "错误:无法执行 $sql. " . mysqli_error($link);
}
}
//结束语句
mysqli_stmt_close($stmt);
}
//关闭连接
mysqli_close($link);
?>
python语言:
++语言:
//这个是注释
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
/*下面是段落注释
1.测试
2.测试完成
*/
VB.net语言
' NOTE: You can use the "Rename" command on the context menu to change the class name "Service" in code, svc and config file together.
Public Class Service
Implements IService
Public Sub New()
End Sub
Dim stocks As String(,) =
{
{"RELIND", "Reliance Industries", "1060.15"},
{"ICICI", "ICICI Bank", "911.55"},
{"JSW", "JSW Steel", "1201.25"},
{"WIPRO", "Wipro Limited", "1194.65"},
{"SATYAM", "Satyam Computers", "91.10"}
}
Public Function GetPrice(ByVal symbol As String) As Double _
Implements IService.GetPrice
Dim i As Integer
'it takes the symbol as parameter and returns price
For i = 0 To i = stocks.GetLength(0) - 1
If (String.Compare(symbol, stocks(i, 0)) = 0) Then
Return Convert.ToDouble(stocks(i, 2))
End If
Next i
Return 0
End Function
Public Function GetName(ByVal symbol As String) As String _
Implements IService.GetName
' It takes the symbol as parameter and
' returns name of the stock
Dim i As Integer
For i = 0 To i = stocks.GetLength(0) - 1
If (String.Compare(symbol, stocks(i, 0)) = 0) Then
Return stocks(i, 1)
End If
Next i
Return "Stock Not Found"
End Function
End Class
汇编语言:
section .text
global _start ;必须为链接器(ld)声明
_start: ;告诉链接器入口点
mov edx,len ;消息长度
mov ecx,msg ;写消息
mov ebx,1 ;文件描述符 (stdout)
mov eax,4 ;系统调用号 (sys_write)
int 0x80 ;调用内核
mov eax,1 ;系统调用号 (sys_exit)
int 0x80 ;调用内核
section .data
msg db 'Hello, world!', 0xa ;要打印的字符串
len equ $ - msg ;字符串的长度
LISP语言:
(defun LM:random (Var / x)
(/ (setq x 4294967296.0
seed (rem (1+ (* 1664525.0
(cond (seed)
((getvar var))
)
)
)
x
)
)
x
)
)
(defun Rand (a b var)
(fix (+ a (* (LM:random var) (- b a -1))))
)