下例:获得2012-5-1号之前一天的日期
<?php
//将时间点转换为时间戳
$date = strtotime('2012-5-1');
//输出一天前的日期,在时间戳上减去一天的秒数
echo date('Y-m-d',$date - 1*24*60*60);
?>
下例:获得2012-5-1号之前一天的日期
<?php
//将时间点转换为时间戳
$date = strtotime('2012-5-1');
//输出一天前的日期,在时间戳上减去一天的秒数
echo date('Y-m-d',$date - 1*24*60*60);
?>
先看chr函数
chr() 函数从指定的 ASCII 值返回字符。
<?php
session_start();
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');
下面是程序代码:
同样的思路,php用rmdir和unlink递归删除多级目录的代码:
/**
+----------------------------------------------------------
* UBB 解析
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
function ubb($Text) {
$Text=trim($Text);
$Text=ereg_replace("n","<br>",$Text);
$Text=preg_replace("/t/is"," ",$Text);
$Text=preg_replace("/[hr]/is","<hr>",$Text);
$Text=preg_replace("/[separator]/is","<br/>",$Text);
$Text=preg_replace("/[h1](.+?)[/h1]/is","<h1>1</h1>",$Text);
$Text=preg_replace("/[h2](.+?)[/h2]/is","<h2>1</h2>",$Text);
$Text=preg_replace("/[h3](.+?)[/h3]/is","<h3>1</h3>",$Text);
$Text=preg_replace("/[h4](.+?)[/h4]/is","<h4>1</h4>",$Text);
$Text=preg_replace("/[h5](.+?)[/h5]/is","<h5>1</h5>",$Text);
$Text=preg_replace("/[h6](.+?)[/h6]/is","<h6>1</h6>",$Text);
$Text=preg_replace("/[center](.+?)[/center]/is","<center>1</center>",$Text);
//$Text=preg_replace("/[url=([^[]*)](.+?)[/url]/is","<a href=1 target='_blank'>2</a>",$Text);
$Text=preg_replace("/[url](.+?)[/url]/is","<a href="1" target='_blank'>1</a>",$Text);
$Text=preg_replace("/[url=(http://.+?)](.+?)[/url]/is","<a href='1' target='_blank'>2</a>",$Text);
$Text=preg_replace("/[url=(.+?)](.+?)[/url]/is","<a href=1>2</a>",$Text);
$Text=preg_replace("/[img](.+?)[/img]/is","<img src=1>",$Text);
$Text=preg_replace("/[imgs(.+?)](.+?)[/img]/is","<img 1 src=2>",$Text);
$Text=preg_replace("/[color=(.+?)](.+?)[/color]/is","<font color=1>2</font>",$Text);
$Text=preg_replace("/[colorTxt](.+?)[/colorTxt]/eis","color_txt('1')",$Text);
$Text=preg_replace("/[style=(.+?)](.+?)[/style]/is","<div class='1'>2</div>",$Text);
$Text=preg_replace("/[size=(.+?)](.+?)[/size]/is","<font size=1>2</font>",$Text);
$Text=preg_replace("/[sup](.+?)[/sup]/is","<sup>1</sup>",$Text);
$Text=preg_replace("/[sub](.+?)[/sub]/is","<sub>1</sub>",$Text);
$Text=preg_replace("/[pre](.+?)[/pre]/is","<pre>1</pre>",$Text);
$Text=preg_replace("/[emot](.+?)[/emot]/eis","emot('1')",$Text);
$Text=preg_replace("/[email](.+?)[/email]/is","<a href='mailto:1'>1</a>",$Text);
$Text=preg_replace("/[i](.+?)[/i]/is","<i>1</i>",$Text);
$Text=preg_replace("/[u](.+?)[/u]/is","<u>1</u>",$Text);
$Text=preg_replace("/[b](.+?)[/b]/is","<b>1</b>",$Text);
$Text=preg_replace("/[quote](.+?)[/quote]/is","<blockquote>引用:<div style='border:1px solid silver;background:#EFFFDF;color:#393939;padding:5px' >1</div></blockquote>", $Text);
$Text=preg_replace("/[code](.+?)[/code]/eis","highlight_code('1')", $Text);
$Text=preg_replace("/[php](.+?)[/php]/eis","highlight_code('1')", $Text);
$Text=preg_replace("/[sig](.+?)[/sig]/is","<div style='text-align: left; color: darkgreen; margin-left: 5%'><br><br>--------------------------<br>1<br>--------------------------</div>", $Text);
return $Text;
}
在PHP中, 使用我最喜欢的最强大的CURL,嘿嘿
下面是在万网查询域名的实例代码
下面实例是告诉我们在论坛有看到关于多少秒钟前发了帖子等这些功能,
分析
-设计一个程序流程
1.功能需要
2.页面设计
3.数据库设计
4.代码设计
5.调试发布
-表单
1.form></form>
2.method:表单数据传输到服务器的方法
post(表示在Http请求中嵌入表单数据)
get (表示将表单数据附加到请求该页的URL) 默认方法
区别:
a.Get传输数据量小,这主要是受URL长度限制;而Post可以传输大量数据。
b.Get安全性比较低,但执行效率比Post好。
接收参数:
POST方式:$_POST['name']
GET方式:$_GET['name']
注意:$_POST与$_GET必须为大写;
php5.0以上版本不加引号会报notice级别错误,要养成良好书写习惯,规范化。当然关闭display_error就另当别论。
充电
$_POST:它是由HTTP POST方法传递的变量组成的数组
$_GET: 它是由HTTP GET方法传递的变量组成的数组
$_COOKIE:它是由HTTP Cookies传递的变量组成的数组
$_SESSION:它是包含当前脚本中会话变量的数组
建议
1.GET安全性较POST差,包含机密信息的话建议使用POST
2.分页时使用GET
3.常用控件
a.单行文本框 <input type=text>
多行文本框 <textarea></textarea>
b.密码框 <input type=password>
c.多选框 <input type=checkbox checked> (checked属性表示选中状态)
d.单选框 <input type=radio checked> (checked同上)
e.下拉菜单
<select>
<option selected></option> //selected指定该选项的初始状态为选中
</select>
f.提交按钮 <input type=submit>
重置按钮 <input type=reset>
4.日期/时间函数
php:date,time;
mysql:now
-javascript验证
onsubmit:当提交按钮点击时触动,如果内容为"return function_name();"函数返回FALSE,则不提交表单。
-初识COOKIE
setcookie(name,value,time);
注意:php的cookie必须刷新一次才能生效。
[PHP]代码
function extract_emails($str){
如
$array = file('phprm.com.txt');