$a=array("red", "green", "blue", "yellow");
count($a); //得到4
unset($a[1]); //删除第二个元素
count($a); //得到3
echo $a[2]; //数组中仅有三个元素,本想得到最后一个元素,但却得到blue,
echo $a[1]; //无值
php access 留言板程序
*/
error_reporting(0);
$conn = new com("adodb.connection");
$conn->open("driver={microsoft access driver (*.mdb)}; dbq=" . realpath("db.mdb "));
$rs=new com("adodb.recordset");
php 过滤html标签的函数代码
//最直接过滤html方法
strip_tags();
ajax php 聊天室实例代码
获取当前页面的url地址php代码
<?php
// 说明:获取无参数url
function curpageurl()
{
$pageurl = 'http';
php生成随机密码函数(四款)
方法一
function generate_password( $length = 8 ) {
// 密码字符集,可任意添加你需要的字符
$chars = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|';
php删除目录及目录下所有文件子目录
<?php教程
set_time_limit(0);
$filenum=0;
function deldir($dir){
global $filenum;
$dh=opendir($dir);
while ($file=readdir($dh)){
if($file!="."&&$file!=".."){
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)){
unlink($fullpath);
if(($filenum %100)==0){
echo "*";
}
$filenum=$filenum+1;
}else{
deldir($fullpath);
}
}
}
closedir($dh);
}
deldir("/www.phprm.com/");
echo "delete cache file success. total:".$filenum;
?>
php判断远程图片是否存在
function img_exits($http://pic2.phprm.com/2010/08/24/url.jpg)
{
$ch = curl_init();
curl_setopt($ch, curlopt_url,$url);
curl_setopt($ch, curlopt_nobody, 1); // 不下载
curl_setopt($ch, curlopt_failonerror, 1);
curl_setopt($ch, curlopt_returntransfer, 1);
php jquery 验证码代码
<?php
//调用此页面,如果下面的式子成立,则生成验证码图片
if($_get['action']=='verifycode'){
rand_create();
}
//验证码图片生成
php mysq数据编辑更新实例
$db = mysql教程_connect("localhost", "phpdb", "phpdb");
mysql_select_db("test",$db);
// 如果提交了submit按钮
if ($submit) {
// 如果没有id,则是在增加记录,否则是在修改记录
if ($id) {
$sql = "update employees set first='$first',last='$last', address='$address',position='$position' where id=$id";
}
else {
$sql = "insert into employees (first,last,address,position) values ('$first','$last','$address','$position')";
}
// 向数据库教程发出sql命令
$result = mysql_query($sql);
echo "记录修改成功!<>";
echo "<a href='$php_self'>返回</a>";
}
elseif ($delete) {
// 删除一条记录
$sql = "delete from employees where id=$id";
$result = mysql_query($sql);
echo "记录删除成功!<>";
echo "<a href='$php_self'>返回</a>";
}
else {
// 如果还没有按submit按钮,那么执行下面这部分程序
if (!$id) {
// 如果不是修改状态,则显示员工列表
$result = mysql_query("select * from employees",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href="%s?id=%s">%s %s</a> ",
$php_self, $myrow["id"], $myrow["first"], $myrow["last"]);
printf("<a href="%s?id=%s&delete=yes">(delete)</a><br>", $php_self, $myrow["id"]);
}
}
?>
<a href="<?php echo $php_self?>">返回</a>
<form method="post" action="<?php echo $php_self?>">
<?php
if ($id) {
// 是在编辑修改状态,因些选择一条记录
$sql = "select * from employees where id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$first = $myrow["first"];
$last = $myrow["last"];
$address = $myrow["address"];
$position = $myrow["position"];
// 显示id,供用户编辑修改
?>
<input type=hidden name="id" value="<?php echo $id ?>">
<?php
}
?>
名:<input type="text" name="first" value="<?php echo $first ?>">
姓:<input type="text" name="last" value="<?php echo $last ?>">
<br>
住址:<input type="text" name="address" value="<?php echo $address ?>">
职位:<input type="text" name="position" value="<?php echo $position ?>">
<br>
<input type="submit" name="submit" value="输入信息">
</form>
<?php
}
?>
</body>
</html>
简单实用php mysql分页代码
$qh=mysql_query("select count(*) as rcnt from table where your_condition_here order by whatever");
$data=mysql_fetch_array($qh);
$nr=$data["rcnt"];
//判断偏移量参数是否传递给了脚本,如果没有就使用默认值0
php上传图片代码(同时图片保存到数据库)
// 连接数据库
$conn = mysql_connect("localhost", "phpdb", "phpdb");
mysql_select_db("test",$conn);
?>
<?
// 取得网页的参数
$id=$_post['id'];