代码如下 | 复制代码 |
//获得图片的格式,包括jpg,png,gif //判断上传文件类型 //另类的读取文件与图片类型 function checktitle($filename) {
|
?>
我们经常会碰到采集内容时,要补全地址是吧,下面我们来看看这款php把相对路径转换成绝对路径方法吧。相对路径转化成绝对路径
代码如下 | 复制代码 |
function relative_to_absolute($content, $feed_url) { if ($server_url == '') { if (isset($protocol[0])) { |
//取得所有链接
代码如下 | 复制代码 |
function get_all_url($code){ preg_match_all('/<as+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)</a>/i',$code,$arr); return array('name'=>$arr[2],'url'=>$arr[1]); } |
定义和用法
header() 函数向客户端发送原始的 http 报头。
认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数(在 php教程 4 以及更高的版本中,您可以使用输出缓存来解决此问题):
<html>
实例一
代码如下 | 复制代码 |
<?php # script 2.7 - view_tasks.php // connect to the database: $dbc = @mysql教程i_connect ('localhost', 'username', 'password', 'test') or die ('<p>could not connect to the database!</p></body></html>'); // get the latest dates as timestamps教程: $q = 'select unix_timestamp(max(date_added)), unix_timestamp(max(date_completed)) from tasks'; $r = mysqli_query($dbc, $q); list($max_a, $max_c) = mysqli_fetch_array($r, mysqli_num); // determine the greater timestamp: $max = ($max_a > $max_c) ? $max_a : $max_c; // create a cache interval in seconds: $interval = 60 * 60 * 6; // 6 hours // send the header: header ("last-modified: " . gmdate ('r', $max)); header ("expires: " . gmdate ("r", ($max + $interval))); header ("cache-control: max-age=$interval"); ?> |
实例二
代码如下 | 复制代码 |
<?php |
提示用户保存一个生成的 pdf 文件(content-disposition 报头用于提供一个推荐的文件名,并强制浏览器显示保存对话框):
代码如下 | 复制代码 |
<?php // 文件将被称为 downloaded.pdf // pdf 源在 original.pdf 中 |
<html>
<body>
代码如下 | 复制代码 |
<script language="网页特效"> } <html> <form name="form1" method="post" action="regok.php" enctype='multipart/form-data' onsubmit="return checkreg()" > </body> |
</html>
<?php
代码如下 | 复制代码 |
//初始化session // 加密密码 // 连接数据库,注册用户 // 获得注册用户的自动id,以后使用此id才可登录 // 注册成功,自动登录,注册session变量 |
*/
代码如下 | 复制代码 |
// 连接和选择数据库 // 修改记录部分 // 删除记录部分 /* |
?>