<?php
//首先假设一个时间
$dt= "2010-09-06 11:19:56";
echo "时间:".$dt."<br>";
//将此时间格式化为Unix时间戳
$tm= strtotime($dt);
echo "此时间的Unix时间戳:".$tm."<br>";
?>
实例
php date()和gmdate()区别描述
date — 格式化一个本地时间/日期
date/time 函数允许您提取并格式化服务器上的日期和时间。
php下导入.sql到数据库的方法
php 购物车程序
<?php
class Shopcar
{
//商品列表
public $productList=array();
/**
*
* @param unknown_type $product 传进来的商品
* @return true 购物车里面没有该商品
*/
public function checkProduct($product)
{
for($i=0;$i<count($this->productList);$i++ )
{
if($this->productList[$i]['name']==$product['name'])
return $i;
}
return -1;
php ajax 用户登录退出
本文章主要讲到了jquery中的ajax和php结合,实现用户无刷新登录效果,有需要的朋友可以参考一下。
本例我们使用Mysql数据库,创建一张user表,表结构如下:
PHP中英数字混排字符串的截取
function smssubstr($string, $length) {
if(strlen($string) <= $length) {
return $string;
}
$strcut = '';
for($i = 0; $i < $length; $i++) {
$strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
}
return $strcut;
}
php fsockopen模仿用户post数据
<?php
function wfopen(http://pic3.phprm.com/2011/10/08/$url.jpg,$post='',$cookie='',$timeout=15) {
$matches = parse_url($url);
$out = "POST {$matches['path']} HTTP/1.0rn";
$out .= "Accept: */*rn";
$out .= "Accept-Language: zh-cnrn";
$out .= "Content-Type: application/x-www-form-urlencodedrn";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT] rn";
$out .= "Host: {$matches['host']}rn";
$out .= 'Content-Length: '.strlen($post)."rn";
$out .= "Connection: Closern";
$out .= "Cache-Control: no-cachern";
$out .= "Cookie: $cookiernrn";
$out .= $post;
$socket = @fsockopen($matches['host'],80,$errno,$errstr,$timeout) or die("$errstr($errno)");
fwrite($socket,$out);
$header = $data = "";
while($infos = trim(fgets($socket,4096))) {
$header.=$infos;
}
while(!feof($socket)) {
$data .= fgets($socket,4096);
}
return $data;
}
echo wfopen('http://localhost/te.php','id=5');
?>
把数字转换成汉字的php代码
php计算几分钟前发贴子
函数tranTime()中的参数$time必须为Unix时间戳,如果不是请先用strtotime()将其转换成Unix时间戳
调用
php随机密码生成程序
Randomly generated password: m1ztpxw8
PHP货币换算程序代码
一款实用的PHP货币换算程序代码哦,有需要的朋友可以参考一下。
Copy the above code into a new file and save it as CurrencyConverter.php. Whenever you need to make a conversion just include the class file and call the ‘convert’ function. You will need to enter your own mysql database variables such as the login details. The example below will convert £2.50 GBP into US Dollars ($).
php ajax用户登录代码
login.html
js代码