查看一下修改前的
which php
/usr/bin/php
编辑配置文件
vi ~/.bash_profile
加入一行
export PATH="/usr/local/php5-5.6.17-20160108-105408/bin:$PATH"
执行一次命令,或重启电脑
which php
/usr/local/php5-5.6.17-20160108-105408/bin/php
查看一下修改前的
which php
/usr/bin/php
编辑配置文件
vi ~/.bash_profile
加入一行
export PATH="/usr/local/php5-5.6.17-20160108-105408/bin:$PATH"
执行一次命令,或重启电脑
which php
/usr/local/php5-5.6.17-20160108-105408/bin/php
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.3
http://php-osx.liip.ch/
CentOS 7.1 安装PHP 5.4.16
yum -y install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap
CentOS 7.1 安装Nginx 1.9.3
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl–devel wget
wget http://nginx.org/download/nginx-1.9.4.tar.gz
tar -zxvf nginx-1.9.4.tar.gz
cd nginx-1.9.4
./configure –prefix=/usr/local/nginx
make && make install
/usr/local/nginx/sbin/nginx
yum install -y curl wget tar bzip2 unzip vim-enhanced passwd sudo yum-utils hostname net-tools rsync man gcc gcc-c++ git make automake cmake patch logrotate python-devel libpng-devel libjpeg-devel
yum clean all
yum -y install nginx php-cli php-mysql php-pear php-ldap php-mbstring php-soap php-dom php-gd php-xmlrpc php-fpm php-mcrypt
yum clean all
$uri = (isset($_SERVER[‘HTTPS’]) && strtolower($_SERVER[‘HTTPS’]) !== ‘off’ ? ‘https’ : ‘http’) . ‘://’ . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
如果使用CURL下载从微信手机端上传的图片?参考下面代码
/** * CURL下载文件 成功返回文件名,失败返回false * @param $url * @param string $savePath * @return bool|string * @author Zou Yiliang */ public function downFile($url, $savePath = './uploads') { //$url = 'http://www.baidu.com/img/bdlogo.png'; /* HTTP/1.1 200 OK Connection: close Content-Type: image/jpeg Content-disposition: attachment; filename="cK4q4fLsp7YOlaqxluDOafB.jpg" Date: Sun, 18 Jan 2015 16:56:32 GMT Cache-Control: no-cache, must-revalidate Content-Length: 963704 */ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, TRUE); //需要response header curl_setopt($ch, CURLOPT_NOBODY, FALSE); //需要response body $response = curl_exec($ch); //分离header与body $header = ''; $body = ''; if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == '200') { $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); //头信息size $header = substr($response, 0, $headerSize); $body = substr($response, $headerSize); } curl_close($ch); //文件名 $arr = array(); if (preg_match('/filename="(.*?)"/', $header, $arr)) { $file = date('Ym') . '/' . $arr[1]; $fullName = rtrim($savePath, '/') . '/' . $file; //创建目录并设置权限 $basePath = dirname($fullName); if (!file_exists($basePath)) { @mkdir($basePath, 0777, true); @chmod($basePath, 0777); } if (file_put_contents($fullName, $body)) { return $file; } } return false; }
MySQL
SELECT TO_BASE64(‘abc’), FROM_BASE64(TO_BASE64(‘abc’)); (测试MySQL版本 5.6.20)
PHP
base64_encode(‘abc’);
base64_decode(‘abc’)
//接收GET传值
$name = Yii::app()->request->getQuery(‘name’);
$age = Yii::app()->request->getQuery(‘age’);
$criteria = new CDbCriteria();
//拼装查询条件
if (!empty($name)) {
$criteria->addCondition(‘name like :name’);
$criteria->params[‘:name’] = ‘%’ . $name . ‘%’;
}
if (!empty($age)) {
$criteria->addCondition(‘age = :age’);
$criteria->params[‘:age’] = $age;
}
//分页
$page = new CPagination();
$page->pageSize = 20;
$page->itemCount = User::model()->count($criteria);
$page->applyLimit($criteria);
//排序
$criteria->order = ‘id Desc’;
//查询数据
$users = User::model()->findAll($criteria);
//加载视图
$this->render(‘index’, array(
‘data’ => $data,
‘page’ => $page,
));
{{ “双引号中包含变量#{pageTitle}” }}
{% autoescape false %}
{{ str }} {# 输出文章内容时,不做escape #}
{% endautoescape %}
字符串连接 ~
{% set pageTitle = category.name ~ ‘ – ‘ ~ front.siteInfo(‘name’) %}
上一篇文章《Twig模版引擎简介-Twig使用指南》简单介绍了具有快速、安全、灵活等特性的PHP模板引擎Twig,本文的重点是介绍Twig的安装方法。你有很多种方式来安装Twig。那么如何安装Twig的PHP包呢?让我们按照不同的安装方法来分别说明。
继续阅读
这是Twig的文档,Twig是一个快速、安全、灵活的PHP模板引擎。Twig被广泛运用于Web/PHP项目的开发,更多时候是集成到一些 PHP框架中,如Symfony 1.x、Symfony 2.x、Zend Framework 2.x、Yii Framework 2.x、Slim Framework 等等,当然你也可以在不使用任何框架的情况下直接使用Twig模版引擎来构建你的Web项目。 继续阅读