導航:首頁 > 編程語言 > 經典的php代碼

經典的php代碼

發布時間:2023-03-12 11:23:16

『壹』 最簡單 php 代碼

<?php

mysql_query("insert into guahao values('".$name."','".$nl."','".$shouji."','".$sname."','".$info."')");
?>

『貳』 求個簡單的php代碼

_tags($string, $replace_with_space = true)
{
if ($replace_with_space) {
return preg_replace('!<[^>]*?>!', ' ', $string);
} else {
return strip_tags($string);
}
}

截取字元函數(匹配各種編碼)
function truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false){
if ($length == 0)
return '';

if (is_callable('mb_strlen')) {
if (mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
// $string has utf-8 encoding
if (mb_strlen($string) > $length) {
$length -= min($length, mb_strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1));
}
if (!$middle) {
return mb_substr($string, 0, $length) . $etc;
} else {
return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2);
}
} else {
return $string;
}
}
}
// $string has no utf-8 encoding
if (strlen($string) > $length) {
$length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
}
if (!$middle) {
return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
}
} else {
return $string;
}
}

綜合就是
$arc=strip_tags($arc);
$arc=truncate($arc,200)

『叄』 php最經典,最基礎的代碼,適合入門的

PHP是一種可以嵌入到HTML中的運行在伺服器端的腳本語言,所以為了體現PHP的特性我們可以分兩種模式來實現PHP代碼

1、 PHP嵌入到HTML中,例如index.php

<html>
<head></head>
<body>
<!--因為PHP嵌入到HTML中,所以需要完全區分PHP代碼和HTML代碼-->
<?php
//輸出helloworld
echo'helloworld;
?>
</body>
</html>

2、 PHP獨立文件,只有PHP代碼,例如index.php

<?php

//輸出
echo'helloworld';

//不需要閉合標簽

『肆』 幫忙些段簡單的PHP代碼

<?php
$type
=
$_GET["type"];
////下面這個是進入選擇的值,根據這個值進入頁面
$html
=
"<script>";
$html
.=
"window.location.href='".
$type.".php'";
$html
.=
"</script>";
echo
$html;
//如果你想做別的
switch($type){
case
'qq':
echo
"你進入了QQ,接下來你想做什麼可以在這里再做判斷";
break;
case
'msn'"
echo
"你進入了MSN,接下來你想做什麼可以在這里再做判斷";
break;
}
如果還有別的要求,可以接著說,或著給我發求助之類的,我能幫的會幫的!
?>

閱讀全文

與經典的php代碼相關的資料

熱點內容
網站怎麼用本地伺服器 瀏覽:120
javadoc導入android 瀏覽:517
文件掃描成pdf 瀏覽:696
涼山火災救援命令 瀏覽:54
壓縮機三相檢測 瀏覽:861
linux怎麼安裝光碟 瀏覽:799
寬頻伺服器無響應是為什麼 瀏覽:226
壓縮包內看圖 瀏覽:914
安卓手機如何發現app後台調用情況 瀏覽:561
程序員簡歷工作描述 瀏覽:159
伺服器中強制疾跑的指令是什麼 瀏覽:54
日語命令性 瀏覽:261
免費的程序編譯游戲 瀏覽:892
如何安裝屏蔽的APP 瀏覽:198
豬臉識別app如何下載 瀏覽:156
卓嵐串口伺服器如何使用 瀏覽:440
pdf周振甫 瀏覽:759
程序員35歲生日圖片 瀏覽:629
矩形密封圈的壓縮量 瀏覽:457
信息安全中圖像加密技術畢業論文 瀏覽:538