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

熱點內容
c語言寫編程時需要用什麼輸入法 瀏覽:583
生發程序員 瀏覽:164
高考英語pdf 瀏覽:411
哈利波特忘記伺服器怎麼辦 瀏覽:817
怎麼看其他電腦共享文件夾 瀏覽:506
py文件夾後綴 瀏覽:716
你對我們的app有什麼建議 瀏覽:577
phpgetcookie 瀏覽:140
程序員最煩遇到的單詞 瀏覽:124
開始伺服器升級需要什麼 瀏覽:980
gcc中的編譯選項 瀏覽:188
程序員長沙開滴滴 瀏覽:138
十幾加幾的進位加法演算法 瀏覽:384
c語言實現字母加密成字母 瀏覽:328
linux重啟java服務 瀏覽:53
ubuntu的命令行在哪裡 瀏覽:981
伺服器tk是什麼意思 瀏覽:397
防止軟體加密碼卸載 瀏覽:182
自建伺服器與雲伺服器 瀏覽:542
已解壓車能過戶能買嗎 瀏覽:775