Jun092016
密码保护:php 的两个函数
if (! function_exists ( 'Array2file' )) {
function Array2file($array, $filename) {
file_exists ( $filename ) or touch ( $filename );
$file_contents = "<?php\r\n";
$file_path = pathinfo ( $filename );
// $file_contents .= '$' . $file_path ['filename'] . ' = ';
$file_contents .= 'return ' . var_export ( $array, TRUE );
$file_contents .= "\...阅读全文
要查看留言请输入您的密码。
Jun092016
密码保护:php 获取执行时间 ExecTime()
/**
* 获取执行时间
* 例如:$t1 = ExecTime();
* 在一段内容处理之后:
* $t2 = ExecTime();
* 我们可以将2个时间的差值输出:echo $t2-$t1;
*
* @return int
*/
if (! function_exists ( 'ExecTime' )) {
function ExecTime() {
$time = explode ( " ", microtime () );
$usec = ( double ) $time [0];
$sec = ( double ) $time [1];
return $sec + $usec;
...阅读全文
要查看留言请输入您的密码。
Jun092016
密码保护:php 获得当前的脚本网址 GetCurUrl()
/**
* 获得当前的脚本网址
*
* @return string 返当前的脚本网址
*/
if (! function_exists ( 'GetCurUrl' )) {
function GetCurUrl() {
if (! empty ( $_SERVER ["REQUEST_URI"] )) {
$scriptName = $_SERVER ["REQUEST_URI"];
$nowurl = $scriptName;
} else {
$scriptName = $_SERVER ["PHP_SELF"];
if (empty ( $_SERVER ["QUERY_STRING"] )) {
...阅读全文
要查看留言请输入您的密码。
Jun092016
密码保护:php获取用户真实地址 GetIP()
/**
* 获取用户真实地址
*
* @return string 返回用户ip
*/
if (! function_exists ( 'GetIP' )) {
function GetIP() {
static $realip = NULL;
if ($realip !== NULL) {
return $realip;
}
if (isset ( $_SERVER )) {
if (isset ( $_SERVER ['HTTP_X_FORWARDED_FOR'] )) {
$arr = explode ( ',', $_SERVER ['HTTP_X_FORWARDED_FOR'] );
/* 取X-F...阅读全文
要查看留言请输入您的密码。
Jun092016
密码保护:php短消息函数
/**
* 短消息函数,可以在某个动作处理后友好的提示信息
*
* @param string $msg 消息提示信息
* @param string $gourl 跳转地址
* @param int $onlymsg 仅显示信息
* @param int $limittime 限制时间
* @return void
*/
function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0) {
header ( "Content-type: text/html; ch...阅读全文
作者:绝缘体.. | 分类:PHP | 阅读: |
要查看留言请输入您的密码。
Feb022016
解析提高PHP执行效率的50个技巧
1、用单引号代替双引号来包含字符串,这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量, 单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的”函数”(译注:PHP手册中说echo是语言结构,不是真正的函数,故 把函数加上了双引号)。
2、如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍。
3、$row[‘id’] 的速度是$row[id...阅读全文
Mar222013
PHP文件函数大全
PHP文件函数大全
basename — 返回路径中的文件名部分
chgrp — 改变文件所属的组
chmod — 改变文件模式
chown — 改变文件的所有者
clearstatcache — 清除文件状态缓存
copy — 拷贝文件
delete — 参见 unlink() 或 unset()
dirname — 返回路径中的目录部分
disk_free_space — 返回目录中的可用空间
disk_total_space — 返回一个目录的磁盘总大小
diskfreespace — disk_free_sp...阅读全文
作者:绝缘体.. | 分类:PHP | 阅读: |
Oct292012
php 获取货币汇率api
// 货币汇率
function currency($from_Currency, $to_Currency, $amount) {
// currency ( "USD", "CNY", 1 );
$amount = urlencode ( $amount );
$from_Currency = urlencode ( $from_Currency );
$to_Currency = urlencode ( $to_Currency );
$url = "http://www.google.com/ig/calculator?hl=en&q={$amount}{$from_Currency}=?{$to_Currency}";
$ch = curl_init ();
...阅读全文
作者:绝缘体.. | 分类:PHP | 阅读: |
Oct272012
php empty()和isset()的区别
在使用 php 编写页面程序时,我经常使用变量处理函数判断 php 页面尾部参数的某个变量值是否为空,开始的时候我习惯了使用 empty() 函数,一直也没发现什么,但是今天我却发现了一些问题,因此改用 isset() 函数,问题不再。
顾名思义,empty() 判断一个变量是否为“空”,isset() 判断一个变量是否已经设置。正是这种所谓的“顾名思义”,令我开始时走了些弯路:当一个...阅读全文
作者:绝缘体.. | 分类:PHP | 阅读: |
Oct222012
php获取某网站的快照时间
<html>
<head>
<title>在线演示_php获取某网站的快照时间 http://blog.qita.in</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="百度,baidu,查询快照结果">
<meta name="description" content="php查询网站快照日期: by enenba.com">
</head>
<body>
<?...阅读全文
作者:绝缘体.. | 分类:PHP | 阅读: |