php fscokopen实现数据异步调用代码
php fscokopen实现数据异步调用代码
我们就可以使用fsockopen连接到本地服务器,触发脚本执行,然后立即返回,不等待
脚本执行完成。
function triggerRequest($url,
$post_data
=
array(),
$cookie
=
array())…{
$method
=
"GET"; //可以通过POST或者GET传递一些参数给要触发的脚本
$url_array
=
parse_url($url); //获取URL信息,以便平凑HTTP HEADER
$port
=
isset($url_array['port'])?
$url_array['port'] :
80;
$fp
=
fsockopen($url_array['host'],
$port,
$errno,
$errstr,
30);
if (!$fp) …{
return
FALSE;
}
$getPath
=
$url_array['path'] ."?".
$url_array['query'];
if(!empty($post_data))…{
$method
=
"POST";
}
$header
=
$method
.
"
"
.
$getPath;
$header
.=
" HTTP/1.1rn";
$header
.=
"Host: ".
$url_array['host'] .
"rn
"; //HTTP 1.1 Host域不能省略
/**//*以下头信息域可以省略
$header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en
-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 rn";
$header .= "Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,q=0.5 rn";
$header .= "Accept-Language: en-us,en;q=0.5 ";
$header .= "Accept-Encoding: gzip,deflatern";
*/
$header
.=
"Connection:Closern";
if(!empty($cookie))…{
$_cookie
=
strval(NULL);
foreach($cookie
as
$k
=>
$v)…{
$_cookie
.=
$k."=".$v."; ";
}
$cookie_str
=
"Cookie: "
.
base64_encode($_cookie) ." rn";//传递Cookie
$header
.=
$cookie_str;
}
if(!empty($post_data))…{
$_post
=
strval(NULL);
foreach($post_data
as
$k
=>
$v)…{
$_post
.=
$k."=".$v."&";
}
$post_str
=
"Content-Type: application/x-www-form-urlencodedrn";//POST数据
$post_str
.=
"Content-Length: ".
strlen($_post) ." rn";//POST数据的长度
$post_str
.=
$_post."rnrn "; //传递POST数据
$header
.=
$post_str;
}
fwrite($fp,
$header);
//echo fread($fp, 1024); //我们不关心服务器返回
fclose($fp);
return
true;
}
现在,就可以通过这个函数来触发一个PHP脚本的执行,然后函数就会返回。 我们
就可以接着执行下一步操作了。
还有一个问题就是,当客户端断开连接以后。也就是triggerRequest发送请求后,
立即关闭了连接,那么可能会引起服务器端正在执行的脚本退出。
在 PHP 内部,系统维护着连接状态,其状态有三种可能的情况:
* 0 - NORMAL(正常)
* 1 - ABORTED(异常退出)
* 2 - TIMEOUT(超时)
当 PHP 脚本正常地运行 NORMAL 状态时,连接为有效。当客户端中断连接时,
ABORTED状态的标记将会被打开。远程客户端连接的中断通常是由用户点击 STOP 按钮
导致的。当连接时间超过 PHP 的时限(请参阅set_time_limit() 函数)时,TIMEOUT
状态的标记将被打开。
可以决定脚本是否需要在客户端中断连接时退出。有时候让脚本完整地运行会带来
很多方便,即使没有远程浏览器接受脚本的输出。默认的情况是当远程客户端连接中断
时脚本将会退出。该处理过程可由 php.ini 的 ignore_user_abort 或由 Apache
.conf设置中对应的“php_value ignore_user_abort”以及 ignore_user_abort() 函
数来控制。如果没有告诉PHP 忽略用户的中断,脚本将会被中断,除非通过
register_shutdown_function()设置了关闭触发函数。通过该关闭触发函数,当远程用
户点击 STOP 按钮后,脚本再次尝试输出数据时,PHP将会检测到连接已被中断,并调
用关闭触发函数。
脚本也有可能被内置的脚本计时器中断。默认的超时限制为 30 秒。这个值可以
通过设置 php.ini 的max_execution_time 或 Apache .conf 设置中对应的
“php_valuemax_execution_time”参数或者 set_time_limit()函数来更改。当计数器
超时的时候,脚本将会类似于以上连接中断的情况退出,先前被注册过的关闭触发函数
也将在这时被执行。在该关闭触发函数中,可以通过调用 connection_status() 函数
来检查超时是否导致关闭触发函数被调用。如果超时导致了关闭触发函数的调用,该函
数将返回 2。
需要注意的一点是 ABORTED 和 TIMEOUT 状态可以同时有效。这在告诉 PHP 忽略
用户的退出操作时是可能的。PHP将仍然注意用户已经中断了连接但脚本仍然在运行的
情况。如果到了运行的时间限制,脚本将被退出,设置过的关闭触发函数也将被执行。
在这时会发现函数connection_status() 返回 3。
所以还在要触发的脚本中指明:
ignore_user_abort(TRUE); //如果客户端断开连接,不会引起脚本abort.
set_time_limit(0);//取消脚本执行延时上限
或者,也可以使用:
register_shutdown_function(callback fuction[, parameters]);//注册脚本退出时
执行的函数
php 批量生成缩略图代码
//创建目录(目录, [模式])
function mkdirs($l1, $l2 = 0777){
if(!is_dir($l1)){
//如果目录不存在,递归建立
mkdirs(dirname($l1), $l2);
return @mkdir($l1, $l2);
}
return true;
}
//保存文件(文件, [内容])
function savefile($l1, $l2=''){
if(function_exists(file_put_contents)){
file_put_contents($l1, $l2);
} else{
$fp = @fopen($l1, 'wb');
@fwrite($fp, $l2);
fclose($fp);
}
}
//获取文件后缀(文件)
function getfix($l1){
return end(explode('.', $l1));
}
//是否为允许类型(当前, 允许)
function checkfix($l1, $l2){
if(!is_array($l2)){
$l2 = explode(',', str_replace(' ', '', $l2));
}
return in_array($l1, $l2) ? 1 : 0;
}
class image{
//源地址
var $src;
//新图路径(本地化后)
var $newsrc;
//允许的图类型
var $allowtype = array('.jpg','.gif','.png','.jpeg');
//是否缩略GIF, 为0不处理
var $regif = 0;
//是否保留源文件(1为保留, 0为MD5)
var $keep = 0;
//是否可以覆盖已存在的图片,为0则不可覆盖
var $over = 0;
//图片源目录
var $dir;
//处理后的目录
var $newdir;
function __construct($l1=null, $l2=null){
$this->dir = $l1 ? $l1 : "./images/temp";
$this->newdir = $l2 ? $l2 : "./images/s";
}
function image($l1=null, $l2=null){
$this->__construct($l1, $l2);
}
/**
* 处理后的文件路径
* 将源图片,MD5文件名后保存到新的目录里
*
* @ param rename()
* @ return 处理后的文件名
*/
function reName($src){
//MD5后文件名(例如:3293okoe.gif)
$l1 = substr(md5($src),10,10).strrchr($src,".");
//处理后文件名
$l1 = $this->w.'_'.$this->h.'_'.$l1;
//返回处理后的地址
return $this->newdir.'/'.$l1;
}
/**
* 生成缩略图
*
* @ param Mini(图片地址, 宽度, 高度, 质量)
* 如果要保留原来的文件名,请设置 $o->keep = 1;
* @ return 处理后的图片地址
*/
function Mini($src,$w,$h, $q=80){
$this->src = $src;
$this->w = $w;
$this->h = $h;
//是否处理GIF图
if(strrchr($src, ".") == ".gif" && $this->regif == 0){
return $this->src;
}
//是否保留原文件名,默认不保留
if(!$this->keep){
//改名后的文件地址
$newsrc = $this->reName($src);
} else {
//保持原名
$src = str_replace('\', '/', $src);
$newsrc = $this->newdir.strrchr($src, "/");
}
//如果已存在,直接返回地址
if(file_exists($newsrc) && $this->over == 0){
return $newsrc;
}
//如果是网络文件,先保存
if(strstr($src, "http://") && !strstr($src, $_SERVER['HTTP_HOST'])){
$src = $this->getimg($src);
}
//获取图片属性
$arr = getimagesize($src);
$ow = $arr[0];
$oh = $arr[1];
$ot = $arr[2];
switch($ot){
case 1:
$im = imagecreatefromgif($src);
break;
case 2:
$im = imagecreatefromjpeg($src);
break;
case 3:
$im = imagecreatefrompng($src);
break;
default:
return 0;
}
//处理缩略图
$nim = imagecreatetruecolor($w,$h);
$k1 = round($h/$w,2);
$k2 = round($oh/$ow,2);
if ($k1<$k2){
$oow = $ow;
$ooh = round($ow*$k1);
$sw = 0;
$sh = ($oh-$ooh)/2;
}
else {
$oow = $oh/$k1;
$ooh = $oh;
$sw = ($ow-$oow)/2;
$sh = 0;
}
//生成图片
if(function_exists(imagecopyresampled)){
imagecopyresampled($nim,$im,0,0,$sw,$sh,$w,$h,$oow,$ooh);
}
else {
imagecopyresized($nim,$im,0,0,$sw,$sh,$w,$h,$oow,$ooh);
}
//处理后的目录是否存在
if(!is_dir($this->newdir)){
@mkdir($this->newdir);
}
//保存图片
switch($ot){
case 1:
$rs = imagegif($nim,$newsrc);
break;
case 2:
$rs = imagejpeg($nim,$newsrc,$q);
break;
case 3:
$rs = imagepng($nim,$newsrc);
break;
default:
return 0;
}
//返回处理后路径
return $newsrc;
}
/**
* 保存网络图片
*
* @ param getImg(源图)
* @ return 保存后的本地址址(本地目录的MD5文件名)
*/
function getimg($l1){
$l2 = $this->dir.'/'.substr(md5($l1),10,10).strrchr($l1,".");
//文件存在,直接返回地址
if(file_exists($l2)){
//echo "exits...";
return $l2;
}
//开始获取文件,并返回新路径
$img = file_get_contents($l1);
if($img){
if(!is_dir($this->dir)){
@mkdir($this->dir);
}
savefile($l2, $img);
//echo "file_get..";
return $l2;
}
}
/**
* 转换缩略图(文件名和结构不变)
*
* @ param mini(源地址, 宽度, 高度, 质量 )
* @ return 生成的地址
*/
function reImg($src, $w, $h, $q=80){
$this->keep = 1;
return $this->Mini($src, $w, $h, $q);
}
}
php 面试题猴王算法
<?php
/*
* filename: kingmonkey.php
* author: luochuan wang
* date: April 2nd, 2009
* descript: an arithmetic to a program
* program:
一群猴子排成一圈,按1,2,...,n依次编号。
然后从第1只开始数,数到第m只,把它踢出圈,
从它后面再开始数, 再数到第m只,在把它踢出去...,
如此不停的进行下去, 直到最后只剩下一只猴子为止,那只猴子就叫做大王。
要求编程模拟此过程,输入m、n, 输出最后那个大王的编号。
*/
function getKingMokey($n, $m)
{
$monkey[0] = 0;
//将1-n只猴子顺序编号 入数组中
for($i= 1; $i<= $n; $i++)
{
$monkey[$i] = $i;
}
$len = count($monkey);
//循环遍历数组元素(猴子编号)
for($i= 0; $i< $len; $i= $i)
{
$num = 0;
/*
* 遍历$monkey数组,计算数组中值不为0的元素个数(剩余猴子的个数
)
* 赋值为$num,并获取值不为0的元素的元素值
*/
foreach($monkey as $key => $value)
{
if($value == 0) continue;
$num++;
$values = $value;
}
//若只剩一只猴子 则输出该猴子编号(数组元素值) 并退出循环
if($num == 1)
{
echo $values;
exit;
}
/*
* 若剩余猴子数大于1($num > 1)
* 继续程序
*/
//将第$i只猴子踢出队伍(相应数组位置元素值设为0)
$monkey[$i] = 0;
//打印该猴子位置
echo $i."";
/*
* 获取下一只需要踢出队伍的猴子编号
* 在$m值范围内遍历猴子 并设置$m的计数器
* 依次取下一猴子编号
* 若元素值为0,则该位置的猴子已被踢出队伍
* 若不为0,继续获取下一猴子编号,且计数器加1
* 若取得的猴子编号大于数组个数
* 则从第0只猴子开始遍历(数组指针归零) 步骤同上
* 直到计数器到达$m值 * 最后获取的$i值即为下一只需要踢出队伍的猴
子编号
*/
//设置计数器
for($j= 1; $j<= $m; $j++)
{
//猴子编号加一,遍历下一只猴子
$i++;
//若该猴子未被踢出队伍,获取下一只猴子编号
if($monkey[$i] > 0) continue;
//若元素值为0,则猴子已被踢出队伍,进而循环取下一只猴子编
号
if($monkey[$i] == 0)
{
//取下一只猴子编号
for($k= $i; $k< $len; $k++)
{
//值为0,编号加1
if($monkey[$k] == 0) $i++;
//否则,编号已取得,退出
if($monkey[$k] > 0) break;
}
}
//若编号大于猴子个数,则从第0只猴子开始遍历(数组指针归零)
步骤同上
if($i == $len) $i = 0;
//同上步骤,获取下一只猴子编号
if($monkey[$i] == 0)
{
for($k= $i; $k< $len; $k++)
{
if($monkey[$k] == 0) $i++;
if($monkey[$k] > 0) break;
}
}
}
}
}
//猴子个数
$n = 10;
//踢出队伍的编号间隔值
$m = 3;
//调用猴王获取函数
getKingMokey($n, $m);
?>
用递归的算法
$monkeys = array(1 , 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , 10); //monkey的编号
$m = 4; //数到第几只的那只猴子被踢出去
/* 猴王算法*/
/*面向过程的实现 */
function killMonkey($monkeys , $m , $current = 0){
$number = count($monkeys);
$num = 1;
if(count($monkeys) == 1){
echo $monkeys[0]."成为猴王了";
return;
}
else{
while($num++ < $m){
$current++ ;
$current = $current%$number;
}
echo $monkeys[$current]."的猴子被踢掉了<br/>";
array_splice($monkeys , $current , 1);
killMonkey($monkeys , $m , $current);
}
}
killMonkey($monkeys , $m);
<?php
require('path.inc.php');
header('content-Type: text/html; charset=utf-8');
$borough_id = intval($_GET['id']);
if(!$borough_id){
echo '
<script>
parent.document.getElementById('mapDiv').style.display="none";
parent.document.getElementById('mapDivLink').style.display="none";
</script>
';
exit;
}
$borough = new Borough($query);
$boroughInfo = $borough->getInfo($borough_id,'*',1,true);
//charsetIconv($boroughInfo,'gbk','utf-8');
$pos = strpos($boroughInfo['borough_name'],'(');
if($pos!==false){
$boroughInfo['borough_name'] = substr($boroughInfo['borough_name'],0,$pos);
}
$boroughInfo['borough_address'] = iconv('gb2312','utf-8',$boroughInfo['borough_address']);
$boroughInfo['borough_name'] = iconv('gb2312','utf-8',$boroughInfo['borough_name']);
$pos = strpos($boroughInfo['borough_name'],'(');
if($pos!==false){
$boroughInfo['borough_name'] = substr($boroughInfo['borough_name'],0,$pos);
}
if(strpos($boroughInfo['borough_name'],'福州')===false){
$boroughInfo['borough_name'] = "福州".$boroughInfo['borough_name'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>小区地图</title>
<script src="<?php echo $cfg['path']['js'].'jquery.js'; ?>" type="text/javascript"></script>
<script src="http://ditu.google.com/maps?file=api&v=2.x&key=ABQIAAAAHhTjWVGPsP7PRmx_R_91ZRTVyAFvJakBKxQFkhQ3JHiKjMJ6fhSBvkRl-6priBh_xdqXZcn6jaYGDw&hl=zh-CN" type="text/javascript"></script>
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
document.domain="fangke.cc";
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
//map.setCenter(new GLatLng(39.917, 116.397), 13);
geocoder = new GClientGeocoder();
map.addControl(new GLargeMapControl());
//map.addControl(new GMapTypeControl());
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
parent.document.getElementById('mapDiv').style.display="none";
parent.document.getElementById('mapDivLink').style.display="none";
} else {
$.post("ajax.php", { point: point,action:"point", id: "<?php echo $boroughInfo['id'];?>" } ,function(data){
//alert(data);
});
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address+"<br><span style='font-size:12px; color:#999; line-height:150%;'><?php echo $boroughInfo['borough_address']; ?></span><br><a href='<?php echo $cfg['url_community'];?>sale.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>二手房源:<?php echo $boroughInfo['sell_num']; ?>套</a><br><a href='<?php echo $cfg['url_community'];?>rent.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>出租房源:<?php echo $boroughInfo['rent_num']; ?>套</a>");
}
}
);
}
}
function setPoint(point){//php教程
eval("var latlng = new GLatLng"+point+";");
map.setCenter(latlng, 13);
var marker = new GMarker(latlng);
map.addOverlay(marker);
marker.openInfoWindowHtml("<a href='<?php echo $cfg['url_community'];?>g-<?php echo $borough_id ?>.html' style='font-size:14px; color:#000; line-height:150%;' target='_blank'><?php echo $boroughInfo['borough_name']; ?></a><br><span style='font-size:12px; color:#999; line-height:150%;'><?php echo $boroughInfo['borough_address']; ?></span><br><a href='<?php echo $cfg['url_community'];?>sale.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>二手房源:<?php echo $boroughInfo['sell_num']; ?>套</a><br><a href='<?php echo $cfg['url_community'];?>rent.php?id=<?php echo $borough_id ?>' style='font-size:12px; color:#f90; line-height:150%;' target='_blank'>出租房源:<?php echo $boroughInfo['rent_num']; ?>套</a>");
}
</script>
</head>
<body onunload="GUnload()">
<div id="map_canvas" style="width: 680px; height: 300px"></div>
</body>
<script type="text/javascript">
initialize();
<?php if ($boroughInfo['layout_map'] ){ ?>
setPoint('<?php echo $boroughInfo['layout_map']; ?>');
<?php }else{ ?>
showAddress('<?php echo $boroughInfo['borough_name']; ?>');
<?php } ?>
</script>
</html>
<?php
/**
* 上传文件
* to : uploadBoroughThumb|borough|picture
* to : 函数名|目录分类|图片类型
*
*/
require('path.inc.php');
$to = $_GET["to"];
$action = $_GET['action'];
if($action==""){
$action = "form";
}
if($action=="doupload"){
echo '<html>';
echo '<head>';
echo '<title>上传成功</title>';
echo "<meta http-equiv="content-type" content="text/html; charset=gb2312">";
echo '</head>';
$store_info = explode('|',$to);
$js_func = $store_info[0];
/* 判断特殊字符 */
if($store_info[1]){
if(!ereg("^[A-Za-z]+$",$store_info[1])){
exit;
}
}
if($store_info[2]){
if(!ereg("^[A-Za-z]+$",$store_info[2])){
exit;
}
}
$upload_conf = require($cfg['path']['conf'].'upload.cfg.php');
$this_config = (array)$upload_conf[$store_info[1]][$store_info[2]];
if(empty($this_config)){
exit;
}
$upload = new UploadFile();//实例化上传对象
//设置可以上传文件的类型
$upload->setAllowFileType($this_config['allowType']);
foreach ($_FILES as $a_file){
if($a_file['error']!=UPLOAD_ERR_NO_FILE) {
try{
$fileName = $upload->upload($a_file,$cfg['path']['root'].'upfile/'.$this_config['originalPath'], 1);
$f_path['url'] = $this_config['originalPath'].$fileName;
$f_path['name'] = $a_file['name'];
$attach_file[] = $f_path;
if(in_array(strtolower(FileSystem::fileExt($f_path['name'])),array('gif','jpeg','jpg','png')) && !$this_config['noResize']){
//先缩略到指定大小
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->resizeImage($this_config['width'],$this_config['height'],$this_config['resizeType']);
$image->save();
//加水印
if($this_config['watermark']){
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->waterMark($this_config['watermarkPic'],$this_config['watermarkPos']);
$image->save();
}
//如果需要再生成缩略图
if($this_config['thumb']){
$image = new Image($cfg['path']['root'].'upfile/'.$this_config['originalPath'].$fileName);
$image->resizeImage($this_config['thumbWidth'],$this_config['thumbHeight'],$this_config['thumbResizeType']);
if($this_config['originalPath']==$this_config['thumbDir']){
//防止存储目录相同时覆盖原有的图片,不存储缩略图直接设置 thumb 属性为空
$image->save(2,$cfg['path']['root'].'upfile/'.$this_config['thumbDir'],'_thumb');
$thumb_path = $this_config['thumbDir'].FileSystem::getBasicName($fileName, false).'_thumb'.FileSystem::fileExt($fileName, true);
}else{
$image->save(1,$cfg['path']['root'].'upfile/'.$this_config['thumbDir']);
$thumb_path = $this_config['thumbDir'].$fileName;
}
}
}
//回传参数
echo "<script>
var parentForm;
if(window.opener){
parentForm = window.opener;
}else{
parentForm = window.parent;
}
parentForm.".$js_func."('".$f_path['url']."','".$f_path['name']."','".$thumb_path."');
</script>";
}catch(Exception $e){
$page->back( $e->getMessage());
}
}else{
echo "<script>
alert('请先浏览文件后点击上传php教程');
history.back();
</script>";
exit;
}
echo "<script>
/*if(window.opener){
window.close();
}else{
history.back();
}*/
history.back();
</script>";
}
echo '</body>';
echo '</html>';
}elseif($action=="form"){
echo '<html>';
echo '<head>';
echo '<title>上传文件</title>';
echo "<meta http-equiv="content-type" content="text/html; charset=gb2312">";
echo '</head>';
echo "<body leftmargin="0" topmargin="0">";
echo "<table cellpadding="2" cellspacing="1" border="0" height="100%" align="left">";
echo "<form action='upload.php?action=doupload&to=".$to."' method='post' enctype='multipart/form-data'>";
echo "<tr ><td valign='middle'>";
echo "<input type='file' name='uploadfile'>";
echo "<input name='submit' type='submit' value='上传'>";
echo "</td></tr>";
echo "</form>";
echo "</table";
echo "</body>";
echo '</html>';
}
?>
相关文章
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
- 本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
- 本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
- 本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
- php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
- php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p> </p> <p> </p> <form name="form1...2016-11-25
- 公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- 一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
- 微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
- 本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
- 小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
php导出csv格式数据并将数字转换成文本的思路以及代码分享
php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07- 这篇文章主要介绍了C#中异步和多线程的相关资料,帮助大家更好的理解和学习c#,感兴趣的朋友可以了解下...2021-01-16
- ecshop商品无限级分类代码 function cat_options($spec_cat_id, $arr) { static $cat_options = array(); if (isset($cat_options[$spec_cat_id]))...2016-11-25
- 多线程和异步操作两者都可以达到避免调用线程阻塞的目的,从而提高软件的可响应性。甚至有些时候我们就认为多线程和异步操作是等同的概念。但是,多线程和异步操作还是有一些区别的。而这些区别造成了使用多线程和异步操作的时机的区别...2020-06-25
- 这篇文章主要介绍了vue项目,代码提交至码云,iconfont的用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-07-30