導航:首頁 > 編程語言 > 經典的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代碼相關的資料

熱點內容
用命令行編譯java 瀏覽:677
筆趣閣app哪個是正版手機app 瀏覽:427
程序員這個工作好嗎 瀏覽:898
agps定位伺服器地址 瀏覽:659
用水做的解壓玩具怎麼做 瀏覽:418
安卓411能下載什麼 瀏覽:304
小海龜logo命令 瀏覽:493
java製作界面 瀏覽:895
台達plc編程電纜製作 瀏覽:249
30多歲當程序員 瀏覽:442
怎樣把表格轉換成pdf 瀏覽:514
行列式分解演算法 瀏覽:291
mscoreedll是什麼文件夾修復 瀏覽:697
什麼app測臉型 瀏覽:43
cf手游刀戰演算法 瀏覽:318
北京壓縮米飯 瀏覽:554
施工員與程序員哪個好 瀏覽:207
vc與word編程 瀏覽:951
androidmenu文字顏色 瀏覽:983
安卓手機玩游戲怎麼會閃退 瀏覽:554