您的位置:首页 > 其它

2014-1/2 日记

2014-01-03 09:39 274 查看
2014-01-01 可以用 ORDER BY RAND 随机获取一条记录,但网上说效率比较慢。
2014-01-05 http://beta.phpformatter.com/ PHP代码的在线格式化
2014-01-11 在ie6使用 width为100%会卡死页面;$insertID = mysql_insert_id();
2014-01-12 在ie6中,window.frames['if_content'].src跳转框架页面不起效果,改为window.frames['if_content'].document.location.href。
2014-02-14 left join中用到or时(fas.fas_IP = bus.bus_ip1 or fas.fas_IP = bus.bus_ip2),索引不起作用。改用两次join来实现。
2014-02-14 `business` bus on (fas.fas_IP = bus.bus_ip1 and bus.bus_status=1) 把bus.bus_status=1写在on里面和写在where条件里面是完全不同的。
2014-02-19 有时候php页面会混进多余的字符进来,这时会导致json_decode解析不了,使用下面这个函数得到正确的json字符串。

function getJsonStr( $value )
{
$jsonStr = "";
preg_match("/(\{.+\})/i",$value,$match);
if( count($match)>0 )
{
$jsonStr = $match[0];
return $jsonStr;
}
return "";
}


2014-02-23 程序运行一次只可用到 session_start 一次,当包含页面也有 session_start 运行就会出错。这时需要用 session_write_close 关闭写入session.
2014-02-25 yum install php-bcmath --enablerepo=ccrepo(enablerepo指定源下载)
yum localinstall php-bcmatch* (yum的本地安装,加*号yum会自动安装所有的依赖关系,而不用rpm一个一个的安装了)
yum localinstall /lib/php-bcmath-5.3.3-3.cc.1.el6.i686.rpm
openssl 使用例子:

$result = openssl_public_encrypt("123456",$crypted,$public_key);
$crypted = base64_encode($crypted);

var_dump($result);
echo $crypted;

$result = openssl_private_decrypt(base64_decode($crypted),$decrypted,$private_key);
var_dump($result);
echo $decrypted;


2014-02-26 PHP_EOL-换行的常量
2014-02-26 JS中

var array = [];
console.log( array[0]['test'] );


上例中会出错,TypeError: array[0] is undefined。但在PHP中 $array[0]['test'] 返回的是 NULL,不会出错。
echo '<?php phpinfo(); ?>' | php 2>&1 |grep -i soap
2014-02-27 一开始我有网页用PHP生成的密钥有错。后来在linux上用openssl的命令生成的 openssl genrsa -out key.pem 1024 生成密钥,然后再用 openssl rsa -in key.pem -pubout -out pub.pem 生成公钥。分别生成了两个文件key.pem和pub.pem。
2014-02-27 http://stackoverflow.com/questions/5838454/inline-block-doesnt-work-in-internet-explorer-7-6 2014-03-01 echo number_format(12345651000,2);
2014-03-01 preg_replace $1
2014-03-05

$a = "";
var_dump( isset($a) ); //true
var_dump( empty($a) ); //true
var_dump( trim($b) ); //""
$c = trim($_GET['b']);
var_dump( isset($c) ); //true
$d = $_GET['b'];
var_dump( isset($d) ); //false
var_dump( isset(trim($d)) ); //Fatal error: Can't use function return value in write context 原因是isset是语句而不是函数


2014-03-05

test();

function test()
{
$a = '测试';
sub();
}

function sub()
{
global $a;
var_dump($a); //null
echo $a;
}


2014-03-07 在linux中要执行shell脚本,可以用 ./ 和 sh 。两者的区别是 sh 不管那个脚本有没有可执行权限,都可以使用这命令。
2014-03-07 pwd 命令可以查看当前工作目录的完整路径。
2014-03-29 删除重复的语句

delete t1 from tem t1,(
select *from tem GROUP BY t_name
having count(1)>1) t2
where t1.id<>t2.id and t1.t_name=t2.t_name


2014-9-17

var cookieArr = /login_username=(.+?)(\b|;)/.exec(document.cookie);
document.cookie = "login_username="+ username +"; expires=" + expires +"; path=/";
console.log(cookieArr);


普通的账号是没问题的,当账号是 xx-xxxx 这种格式时就有问题了。\b居然匹配 - 为单词边界。正确写法应该改为 /login_username=(.+?)($|;)/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: