<?phpnamespace App\Services;use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;class CacheDecorator
{// 公司组织列表缓存keyconst COMPANY_ORGANIZE_KEY = ‘company_organize_%s‘;privatestaticfunction setStringCacheStorage($key, $expireTime, string$data){if ($expireTime) {Redis::setex($key, $expireTime, $data);} else {Redis::set($key, $data);}}/*** 装饰器获取缓存数据* @param $ca...
<?php
$dsn=‘mysql:host=localhost;dbname=mssc‘;
$user=‘root‘;
$password=‘‘;
$status=1;
try {$sql=‘select * from onethink_order where status=:status‘;$dbh=new PDO($dsn,$user,$password);$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $stmt=$dbh->prepare($sql);$stmt->bindParam(‘:status‘,$status);$stmt->execute();//返回插入、更新、删除的受影响行数// echo $stmt->rowCount();//返回...
考虑用PHP实现以下场景: 有一个抓站的URL列表保存在队列里,后台程序读取这个队列,然后转交给子进程去抓取HTML存放到文件里。 为了提高效率,允许多任务并行执行,但为了避免机器负载过高,限制了最大的并行任务数(为了测试方便,我们把这个数设为3),当队列中取到 END标记时,程序结束运行。这个场景用QPM的Supervisor::taskFactoryMode()实现,非常简单。QPM全名是 Quick Process Management Module for PHP. PHP 是强大的web开...
Memcached-1.4.4-14 For Win32 or Win64http://my.oschina.net/u/205403/blog/390256查看 php.ini 可见 session 的默认存储方式是 files,如下session.save_handler = filessession 的默认存储路径为 对于windows为:C:/Windows/Temp对于linux为:未知# windows平台
session.save_path = "N:/path"# linux平台
session.save_path = "/path"我们知道是用 files 文件系统来存储的话,每次 session 时都会生成一个文件,效率很低下,如...
我用的centos系统版本,是6.5版本64位1、配置centos的yum源之前我的阿里云服务器的centos,好像因为没有配置yum源而使用系统自带的,通过yum install libreoffice没找到Libreoffice安装包(当然,这可能是我系统版本的问题,具体就不得而知了,因为后来搞不定又继续更换了其他版本的centos)。yum源配置,因为我使用的是阿里云服务器,所以我使用阿里云的yum源。配置方法:http://mirrors.aliyun.com/help/centos2、安装Libreoffic...
redis3.2中增中了对GEO类型的支持,该类型存储经纬度,提供了经纬设置,查询,范围查询,距离查询,经纬度hash等操作。<?php$redis = new Redis();
$redis->connect(‘127.0.0.1‘, 6379, 60);
$redis->auth(‘‘);//添加成员的经纬度信息
$redis->rawCommand(‘geoadd‘, ‘citys‘, ‘116.40‘, ‘39.90‘, ‘beijing‘);
$redis->rawCommand(‘geoadd‘, ‘citys‘, ‘121.47‘, ‘31.23‘, ‘shanghai‘);
$redis->rawCommand(...
<!DOCTYPE>
<html>
<head><meta http-equiv="Content-type" content="text/html" charset="utf-8"><title>sort table</title><style>*{margin:0px;padding:0px;}body{background:#ccc; }table{width:350px;margin:0 auto;background-color:#eee; }table th{cursor:hand;padding:5px 0;background-color:#999; }table td{background-color:#fff;font-size:16px;font-weight:normal;text-align:center;line-hei...
php使用phpword插件生成word文档php使用phpword插件生成word文档,有需要的朋友可以参考参考。 <?php require_once ‘../libs/PHPWord/PHPWord.php‘; require_once ‘../libs/PHPWord/PHPWord/IOFactory.php‘; require_once ‘../../config.php‘; // require_once ‘../common/conn.php‘; // New Word Document $PHPWord = new PHPWord(); /**********文本格式的word text.php************/ // New portrait section //...
<?php
$url = "图片绝对地址/thumbnail.jpg";
$filename = ‘curl.jpg‘;
getImg($url, $filename);
/**@通过curl方式获取制定的图片到本地*@ 完整的图片地址*@ 要存储的文件名*/function getImg($url = "", $filename = "") {if(is_dir(basename($filename))) {echo "The Dir was not exits";returnfalse;}//去除URL连接上面可能的引号$url = preg_replace( ‘/(?:^[‘"]+|[‘"/]+$)/‘, ‘‘, $url );$hander = curl_init();$fp ...
DES是一种标准的数据加密算法,关于这个算法的详细介绍可以参考wiki和百度百科:wiki百科 百度百科php中有一个扩展可以支持DES的加密算法,是:extension=php_mcrypt.dll在配置文件中将这个扩展打开还不能够在windows环境下使用需要将PHP文件夹下的 libmcrypt.dll 拷贝到系统的 system32 目录下,这是通过phpinfo可以查看到mcrypt表示这个模块可以正常试用了。下面是PHP中使用DES加密解密的一个例子:复制代码 代码如下://$inpu...
代码很简单直接上了<?php/*** @Author: HTL* @Email: Huangyuan413026@163.com* @DateTime: 2015-05-14 16:00:08* @Description: Description*/// 降低PHP默认的错误级别// 只显示除禁用以外的所有错误// 解决因为PHP5.3+版本太高而导致在使用mysql_connect时出现的弃用警告“Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead”error...
前台代码:<html>
<head><title>上传文件</title>
</head>
<body><form enctype="multipart/form-data" action="upload.php" method="post"><input type="file" name="uploadfile" /><input type="submit" value="上传"/></form>
</body>
</html> 后台代码:<?php //上传单文件require ‘HTTP/Upload.php‘;$upload = new HTTP_Upload();$file = $upload->getFiles(‘uploadfile‘);if ($file->isValid()) {$file->moveTo(‘upload...
其实很简单 <?php
/**
*@param $ip target ip
*@param $times ping times
*/
function ping($ip,$times=4)
{
$info = array();
if(!is_numeric($times) || $times-4<0)
{
$times = 4;
}
if (PATH_SEPARATOR==‘:‘ || DIRECTORY_SEPARATOR==‘/‘)//linux
{
exec("ping $ip -c $times",$info);
if (count($info) < 9)
{
...
本文实例讲述了php使用socket post数据到其它web服务器的方法。分享给大家供大家参考。具体实现方法如下:
function post_request($url, $data, $referer=‘‘) {// Convert the data array into URL Parameters like a=b&foo=bar etc.$data = http_build_query($data);// parse the given URL$url = parse_url($url);if ($url[‘scheme‘] != ‘http‘) { die(‘Error: Only HTTP request are supported !‘);}// extract host an...
第一次在Mac下使用ThinkPHP,用到验证码功能时报如题的错误: Call to undefined function Think\imagettftext()然后检查自己的GD库,发现安装上了的。在网上找到解决方案:curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5参考资料来源:http://blog.csdn.net/ayonel613/article/details/51136070 原文:http://www.cnblogs.com/b-ruce/p/5858508.html