PHP生成随机值

function randomkeys($length) {
    $key="";
    $pattern='1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for ($i=0; $i<$length; $i++){
        $key .= $pattern{mt_rand(0,35)};
    }
    return $key;
}

for ($i=0; $i < 10; $i++) {
    echo randomkeys(6);
    echo '<br>';
}

php中常见文件类型的content-type

//定义编码
header( ‘Content-Type:text/html;charset=utf-8 ‘);

//Atom
header(‘Content-type: application/atom+xml’);

//CSS
header(‘Content-type: text/css’);

//Javascript
header(‘Content-type: text/javascript’);

//JPEG Image
header(‘Content-type: image/jpeg’);

//JSON
header(‘Content-type: application/json’);

//PDF
header(‘Content-type: application/pdf’);

//RSS
header(‘Content-Type: application/rss+xml; charset=ISO-8859-1’);

//Text (Plain)
header(‘Content-type: text/plain’);

//XML
header(‘Content-type: text/xml’);

// ok
header(‘HTTP/1.1 200 OK’);

//设置一个404头:
header(‘HTTP/1.1 404 Not Found’);

//设置地址被永久的重定向
header(‘HTTP/1.1 301 Moved Permanently’);

//转到一个新地址
header(‘Location: http://www.example.org/’);
//文件延迟转向:
header(‘Refresh: 10; url=http://www.example.org/’);
print ‘You will be redirected in 10 seconds’;

//当然,也可以使用html语法实现
// Posted on Tags , ,

CentOS安装一些常用包

常用的软件包
Python-pip

rpm -iUvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

#添加EPEL(Extra Packages for Enterprise Linux)源

yum update
yum install python-pip
pip install –upgrade pip

#自更新pip,因为EPEL里面的pip版本还是挺旧的

PHP7+Apache2 Httpd

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w php70w-cli php70w-opcache php70w-common