php简单系统代码,php简单程序
php最经典,最基础的代码,适合入门的
PHP是一种可以嵌入到HTML中的运行在服务器端的脚本语言,所以为了体现PHP的特性我们可以分两种模式来实现PHP代码
1、 PHP嵌入到HTML中,例如index.php
head/head
body
????!--因为PHP嵌入到HTML中,所以需要完全区分PHP代码和HTML代码--
?????php
????????//输出hello?world
????????echo?'hello?world;
?????
/body
/html
2、 PHP独立文件,只有PHP代码,例如index.php
?php
????//输出
????echo?'hello?world';
????
????//不需要闭合标签
求写个比较简单的php登陆页面代码
index.php 录入页代码form id="form1" name="form1" method="post" action="login.php"
table width="400" border="0" align="center" cellpadding="1" cellspacing="1" class="tableborder"
tr
tddiv align="right"用户名:/div/td
td width="244"
input type="text" name="User_name" id="User_name" / /td
/tr
tr
tddiv align="right"密 码:/div/td
tdinput type="Password" name="User_Password" id="User_Password" //td
/tr
tr
td
div align="right"
input type="submit" name="button" id="button" value="提交" /
/div/td
tdinput type="reset" name="button2" id="button2" value="重置" //td
/tr
/table
/form login.php提交页代码?
error_reporting(0);
$mysql_servername = "127.0.0.1";
$mysql_username = "root";
$mysql_password ="123456";
$mysql_database ="first";
mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database);
$U_name=$_POST['user_name'];
$U_passowrd=$_POST['user_password'];
if ($U_name $U_passowrd){
$sql = "SELECT * FROM admin WHERE U_name = '$U_name' and U_password='$U_passowrd'";
$res = mysql_query($sql);
$rows=mysql_num_rows($res);
if($rows){
header("location='c.php'");
exit;
}
echo "script language=javascriptalert('用户名密码错误');history.back();/script";
}else {
echo "script language=javascriptalert('用户名密码不能为空');history.back();/script";
}
?
简单PHP代码
$_env 是环境变量,通过环境方式传递给当前脚本的变量的数组。
$_ENV['defaultapp'] = array('portal.php' = 'portal', 'forum.php' = 'forum', 'group.php' = 'group', 'home.php' = 'home');
是赋值 , 你可以用 var_dump($_env['defaultapp']) 看赋值结果。
--------------------------------------------------------------------
$_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);
环境变量 用.分隔 主域名(你可以 echo $_server['HTTP_HOST']里面有什么)
----------------------------------------------------------------
$url = $domainroot.'forum.php?mod=groupfid='.$domain['id'].'page=1';
构造一个URL 直白点 结果就是: ;fid=1page=1
----------------------------------------
$url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];
结构简化 $url = $a ? (!$b? $c : $d) :$e; 2个3元运算嵌套, 至于看起来复杂的变量都是多维数组的值
求个简单的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代码
$file=file_get_contents("./a.txt");
$count=substr_count($file,"0");
echo $count;
帮忙些段简单的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;
}
如果还有别的要求,可以接着说,或着给我发求助之类的,我能帮的会帮的!
?