Archive for April, 2010
php的session_start函数会附加header信息
Session_start会添加下面这些东西,所以你如果要改这些 header请在Session_start之后修改,否则会被session_start overwrite掉!
| Cache-Control | no-store, no-cache, must-revalidate, post-check=0, pre-check=0 |
| Expires | Thu, 19 Nov 1981 08:52:00 GMT |
| Pragma | no-cache |
php unset Header..
如果php已经输出了header
在下面只需要header(‘Pragma:’);就可以了。。
注意最后有一个:
php 5.3.0以后提供了header_remove这个函数,比上面的方法好多了!但是美中不足的是只有5.3.0以后才能用拉~~
PKCS5填充 PHP DES算法库
-
class Bdes extends CBase {
-
private $key; //密码
-
private $iv; //iv
-
private $mcrypt;
-
private $blockSize;
-
<a href="http://blog.fabrichina.net/archives/201#more-201" class="more-link">Read the rest of this entry »</a>
我常用的一种nginx conf文件的写法
user www www;
worker_processes 10;
error_log /var/nginxlogs/error.log error;
worker_rlimit_nofile 21200;
events
{
use epoll;
worker_connections 21200;
}
http {
upstream javaServer {
server 10.10.10.81:7777;
server 10.10.10.80:7777;
server 10.10.10.81:7777;
}
upstream phpServer {
server localhost:81;
}
upstream cacheServer {
server localhost:82;
}
include mime.types;
default_type application/octet-stream;
server_tokens off;
client_max_body_size 20m;
tcp_nodelay on;
include dhport.conf;
# include cache.dhport.conf;
}
apache vs php httpd.conf初始设置
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
<Directory />
options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
AddDefaultCharset utf-8
这样定虚机的时候能省事多了~~
新版smarty可能导致php __autoload函数失效。。
升级了smarty结果__autoload没了,不明白为什么。。反正回滚了smarty就好了。。。
apache Could not reliably determine the server’s fully 解决。。
Posted by Albert in PHP语言学习, linux 服务器安装 on April 23rd, 2010
修改httpd.conf
ServerName localhost:80
这样就ok了啊~~
编译php VS oci8-1.4.1 报错解决
先是从pecl下载了oci8-1.4.1.tar.gz
./configure –with-php-config=/usr/local/php/bin/php-config –with-oci8=/usr/lib/oracle/10.2.0.3/client
make && make install
make的时候报错了
修改MakeFile
INCLUDES = -I/usr/local/php/include/php -I/usr/include/oracle/10.2.0.3/client
找到includes这里,加上-I/usr/include/oracle/10.2.0.3/client
再make就过了!
写ini文件(配合parse_ini函数的)
这个函数不是我写的,不得不说,他写的太傻了!
-
function write_ini_file($assoc_arr, $path, $has_sections=FALSE) {
-
$content = "";
-
<a href="http://blog.fabrichina.net/archives/179#more-179" class="more-link">Read the rest of this entry »</a>
php生成图片验证码
-
public function valiCodeImage($valicode_name=valicode’)
-
{
-
$str = self::_random(5); //随机生成的字符串
-
$width = 60; //验证码图片的宽度
-
$height = 25; //验证码图片的高度
-
@header("Content-Type:image/png");
-
$im=imagecreate($width,$height);
-
//背景色
-
$back=imagecolorallocate($im,0xFF,0xFF,0xFF);
-
//模糊点颜色
-
$pix=imagecolorallocate($im,187,230,245);
-
//字体色
-
$font=imagecolorallocate($im,40,160,230);
-
//绘模糊作用的点
-
mt_srand();
-
for($i=0;$i<1000;$i++)
-
{
-
imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$pix);
-
}
-
imagestring($im, 5, 7, 5,$str, $font);
-
imagerectangle($im,0,0,$width-1,$height-1,$font);
-
imagepng($im);
-
imagedestroy($im);
-
-
if( empty($valicode_name) ){
-
$valicode_name = valicode’;
-
}
-
$_SESSION[$valicode_name] = $str;
-
//echo $str;
-
}
-
private function _random($len) {
-
$srcstr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-
mt_srand();
-
$strs="";
-
for($i=0;$i<$len;$i++){
-
$strs.=$srcstr[mt_rand(0,61)];
-
}
-
return $strs;
-
}
php内存换算方式。。
-
function memConvert($size) {
-
$unit=array(‘B’,'KB’,'MB’,'GB’,'TB’,'PB’);
-
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).’ ‘.$unit[$i];
-
}
递归返回所有目录
-
function listFile($dir,$files=array()) {
-
$handle = opendir($dir) or return;
-
if(substr($dir,-1)==’/') $dir=substr($dir,0,-1);
-
while (false !== ($file = readdir($handle))) {
-
if((substr($file,0,1)!=’.') && is_dir($dir.’/’.$file)) $this->listFile($dir.’/’.$file,&$files);
-
else {
-
if(substr($file,0,1)==’.') continue;
-
$files[]=$dir.’/’.$file;
-
}
-
}
-
closedir($handle);
-
return $files;
-
}
Recent Comments