手机号码归属地查询代码
if( $_post )
{
$phone=(isset($_post["phone"]))?$_post["phone"]:die ("请返回");
echo "你查询的:$phone,资料:".getphone($phone);
删除数组中某个值元素
//更简单的做法
/*
结果如下:
php 取出周一和周日的时间戳
function getmonsun(){
$curtime=time();
$curweekday = date('w');
//为0是 就是 星期七
$curweekday = $curweekday?$curweekday:7;
php smarty模板生成静态html页面代码
include('./www.phprm.com/smarty/smarty.class.php');
$smarty = new smarty();
$smarty->template_dir = "templates/";
$smarty->compile_dir = "templates_c/";
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
数据库添加、修改、删除基础操作代码(1/4)
require_once('common.php');
$action = $_get['action'];
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.phprm.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>人才列表</title>
<link href="style.css教程" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="wrap">
<div id="main">
<?php
if($action=='add'){
?>
<form action="?action=save" method="post" name="form1">
<table width="300" border="0" cellspacing="0" cellpadding="0" class="post">
<tr>
<td colspan="2">添加人员</td></tr>
<tr><td width="78">登陆账号</td>
<td width="220"><input name="login" type="text" id="login" /></td>
</tr>
<tr>
<td>登陆密码</td>
<td><input name="pws" type="text" id="pws" /></td>
</tr>
<tr>
<td>问题</td>
<td><input name="question" type="text" id="question" /></td>
</tr>
<tr>
<td>答案</td>
<td><input name="answer" type="text" id="answer" /></td>
</tr>
<tr>
<td colspan="2"><input name="button" type="submit" id="button" value=" 添加 " /></td>
</tr>
</table>
</form>
<?php
}
elseif($action=='save'){
$login = isset($_post['login']) ? $_post['login'] : '';
$pws = isset($_post['pws']) ? $_post['pws'] : '';
$question = isset($_post['question']) ? $_post['question'] : '';
$answer = isset($_post['answer']) ? $_post['answer'] : '';
$sql = "insert into person (login,pws,question,answer)
values('$login','$pws','$question','$answer')";
$db->query($sql);
forward('发布成功','href','personlist.php');
}
php通用分页类代码
class dividepage{//分页类
private $total;//要显示的总记录数
private $url;//请求的url地址
private $displaypg;//每页显示的记录数,默认为每页显示10条记录
private $page;//当前页码
private $lastpg;//总页数,即最后一页的页码
private $prepg;//前一页
private $nextpg;//后一页
private $firstcount;//记录条数开始的序号从0开始
private $startd;//记录条数开始的记录号.
private $stopd;//记录条数结束的记录号.
php留言板程序(适合php初学者)(1/4)
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<title>所有留言</title>
<link rel="stylesheet" type="text/css教程" href="style.css" media="all" />
</head>
php检测函数是否存在函数 function_exists
语法
bool function_exists ( string $function_name )
检查的定义的函数的列表,同时内置(内部)和用户定义的,为function_name。
返回值
返回true,如果function_name存在,是一个函数,否则返回false。
*/
php判断类是否存在函数 class_exists
//bool class_exists ( string $class_name [, bool $autoload = true ] )
//此功能是否给定的类被定义检查。this function checks whether or not the given class has been defined.
//返回true,如果class_name是一个定义的类,否则返回false。
//实例
php获取当前文件所有执行的函数和类
array get_defined_functions ( void )
//返回一个多维数组,它包含所有已定义的函数的列表,同时内置(内部)和用户定义的。内部功能将通过$改编[访问"内部"],并在用户定义的使用$改编["用户"](见下面的例子)。
php数字分页类代码(仿百度分页效果)
$conn=mysql教程_connect("localhost","root","");
$db=mysql_select_db("gan");
mysql_query("set names 'gbk'");
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.phprm.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>