问题提出:
做php程序,往往有可能打印一些东西出来,但是涉及到页面的显示,往往打印到后台日志文件中,有的专门有日志函数,为了方便,我就直接用了php5的file_put_contents()函数,通过tail -f /tmp/feedContent.txt. 但是,发现出现:tail: /tmp/feedContent.txt: file truncated 的情况!
估计问题:
查了下google,发现:http://topic.csdn.net/u/20080201/09/2f55ff69-96f9-4960-a6d5-14aa2585dafe.html 这个文章!
看后突然想起我的用法是:
如果文件已存在,原有文件被重写。写日志的程序估计不是简单的追加方式有可能还对文件进行了某些特殊处理,导致tail处理异常
估计是每次都重新写造成。改为:
问题得到解决,再没有提示:
tail: /tmp/feedContent.txt: file truncated!具体查看:FILE_APPEND和tail -f的机制即可。。。
用vi模拟出现tail -f *.txt 出现tail: /tmp/feedContent.txt: file truncated 这个行为:
最后:
用vi 打开:
命令行输入:
在
出现:tail: /tmp/feedContent.txt: file truncated
问题得证!
做php程序,往往有可能打印一些东西出来,但是涉及到页面的显示,往往打印到后台日志文件中,有的专门有日志函数,为了方便,我就直接用了php5的file_put_contents()函数,通过tail -f /tmp/feedContent.txt. 但是,发现出现:tail: /tmp/feedContent.txt: file truncated 的情况!
估计问题:
查了下google,发现:http://topic.csdn.net/u/20080201/09/2f55ff69-96f9-4960-a6d5-14aa2585dafe.html 这个文章!
看后突然想起我的用法是:
file_put_contents("/tmp/feedContent.txt",$record_info);
$record_content_array = urlencode(serialize($record_info));
$flag = $myfrd->sendSnsFeeds($uid, DEF_RECORD_FEED_TYPE,$record_content_array,DEF_RECORD_FEED_SETTING);
file_put_contents("/tmp/feedContent.txt",$record_content_array);
$record_content_array = urlencode(serialize($record_info));
$flag = $myfrd->sendSnsFeeds($uid, DEF_RECORD_FEED_TYPE,$record_content_array,DEF_RECORD_FEED_SETTING);
file_put_contents("/tmp/feedContent.txt",$record_content_array);
如果文件已存在,原有文件被重写。写日志的程序估计不是简单的追加方式有可能还对文件进行了某些特殊处理,导致tail处理异常
估计是每次都重新写造成。改为:
file_put_contents("/tmp/feedContent.txt",$record_info,FILE_APPEND);
$record_content_array = urlencode(serialize($record_info));
$flag = $myfrd->sendSnsFeeds($uid, DEF_RECORD_FEED_TYPE,$record_content_array,DEF_RECORD_FEED_SETTING);
file_put_contents("/tmp/feedContent.txt",$record_content_array,FILE_APPEND);
$record_content_array = urlencode(serialize($record_info));
$flag = $myfrd->sendSnsFeeds($uid, DEF_RECORD_FEED_TYPE,$record_content_array,DEF_RECORD_FEED_SETTING);
file_put_contents("/tmp/feedContent.txt",$record_content_array,FILE_APPEND);
问题得到解决,再没有提示:
tail: /tmp/feedContent.txt: file truncated!具体查看:FILE_APPEND和tail -f的机制即可。。。
用vi模拟出现tail -f *.txt 出现tail: /tmp/feedContent.txt: file truncated 这个行为:
最后:
用vi 打开:
vi /tmp/feedContent.txt
命令行输入:
g/^/d
清空里面内容,然后wq!保存在
tail -f /tmp/feedContent.txt
出现:tail: /tmp/feedContent.txt: file truncated
问题得证!
往往在取得用户uid后,通过函数取得姓名,然后组合为数组输出拱smarty使用的示例!
<?php
$arry_all[2] =array("uid"=>001,"sex"=>"man");
$arry_all[3] =array("uid"=>001,"sex"=>"man");
$arry_all[4] =array("uid"=>001,"sex"=>"man");
$arry_all[5] =array("uid"=>001,"sex"=>"man");
$arry_all[6] =array("uid"=>001,"sex"=>"man");
$name_array = array(array("name0"=>"jianxin","name1"=>"zhujianxin"),"zaifeng","xichen","xiangdong","wangfang");
$i=0;
foreach($arry_all as $k=>$v)
{
$arry_all[$k]['name']=$name_array[$i];
$i=$i+1;
}
print_r($arry_all);
?>
$arry_all[2] =array("uid"=>001,"sex"=>"man");
$arry_all[3] =array("uid"=>001,"sex"=>"man");
$arry_all[4] =array("uid"=>001,"sex"=>"man");
$arry_all[5] =array("uid"=>001,"sex"=>"man");
$arry_all[6] =array("uid"=>001,"sex"=>"man");
$name_array = array(array("name0"=>"jianxin","name1"=>"zhujianxin"),"zaifeng","xichen","xiangdong","wangfang");
$i=0;
foreach($arry_all as $k=>$v)
{
$arry_all[$k]['name']=$name_array[$i];
$i=$i+1;
}
print_r($arry_all);
?>
好像是由于我的curl_post有些问题,然后用到了如下函数的post:
我的curl_post:
首先贴上生产环境的代码段【建鑫编写】:
不过我对这个哥们用到ksort函数的file_get_contents()觉得不错:
阅读全文
我的curl_post:
function curl_post($url, $content)
{
$str_url = $url;
$str_post_data = $content;
$ch_curl = curl_init ();
curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 3 );
curl_setopt ( $ch_curl, CURLOPT_HEADER, false );
curl_setopt ( $ch_curl, CURLOPT_POST, 1 );
curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch_curl, CURLOPT_URL, $str_url );
curl_setopt ( $ch_curl, CURLOPT_POSTFIELDS, $str_post_data );
$str_return = curl_exec ( $ch_curl );
if ($str_return === false)
return false;
curl_close ( $ch_curl );
return $str_return;
}
{
$str_url = $url;
$str_post_data = $content;
$ch_curl = curl_init ();
curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 3 );
curl_setopt ( $ch_curl, CURLOPT_HEADER, false );
curl_setopt ( $ch_curl, CURLOPT_POST, 1 );
curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch_curl, CURLOPT_URL, $str_url );
curl_setopt ( $ch_curl, CURLOPT_POSTFIELDS, $str_post_data );
$str_return = curl_exec ( $ch_curl );
if ($str_return === false)
return false;
curl_close ( $ch_curl );
return $str_return;
}
首先贴上生产环境的代码段【建鑫编写】:
<?php
function request_post($url,$data,&$result)
{
$ctx = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$context = stream_context_create($ctx);
$result = file_get_contents($url,false,$context);
if ($result === false){
return false;
}
return true;
}
request_post("http://localhost","aa=aaa",$result);
echo $result;
?>
function request_post($url,$data,&$result)
{
$ctx = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$context = stream_context_create($ctx);
$result = file_get_contents($url,false,$context);
if ($result === false){
return false;
}
return true;
}
request_post("http://localhost","aa=aaa",$result);
echo $result;
?>
不过我对这个哥们用到ksort函数的file_get_contents()觉得不错:
function Post($url, $post = null)
{
$context = array();
if (is_array($post))
{
ksort($post);
$context['http'] = array
(
'method' => 'POST',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
$data = array
(
'name' => 'test',
'email' => 'test@gmail.com',
'submit' => 'submit',
);
echo Post('http://www.url.com/to/submit.php', $data);
{
$context = array();
if (is_array($post))
{
ksort($post);
$context['http'] = array
(
'method' => 'POST',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
$data = array
(
'name' => 'test',
'email' => 'test@gmail.com',
'submit' => 'submit',
);
echo Post('http://www.url.com/to/submit.php', $data);

php.ini可配置,只能是选取一种方式(cookie和get方式的传递),php以前session机制就是通过get参数方式(每次得编程解析这个get的参数值),为此get方式没大有人用了!
Get 方式:
好像在ver4以后改为cookie模式了,把php ini中session 处理方式改为 get参数方式!
cookie方式:
Set-Cookie: PHPSESSID=bmmc3mfc94ncdr15ujitjogma3; path=/ session_id=bmmc3mfc94ncdr15ujitjogma3 (加密串)
这是服务器向客户端浏览器写一个cookie,名字是PHPSESSID,值是bmmc3mfc94ncdr15ujitjogma3,这个值实际就是所谓的session_id。
如果禁用了cookie,seesion也就失效了。。。如果客户端没有禁用 Cookie,则 Cookie 在启动 Session 会话的时候扮演的是存储 Session ID 和 Session 生存期的角色!!!
cookie处理session id等参看:http://www.xiangdong.org/blog/post/1608/
Get 方式:
好像在ver4以后改为cookie模式了,把php ini中session 处理方式改为 get参数方式!
cookie方式:
Set-Cookie: PHPSESSID=bmmc3mfc94ncdr15ujitjogma3; path=/ session_id=bmmc3mfc94ncdr15ujitjogma3 (加密串)
这是服务器向客户端浏览器写一个cookie,名字是PHPSESSID,值是bmmc3mfc94ncdr15ujitjogma3,这个值实际就是所谓的session_id。
如果禁用了cookie,seesion也就失效了。。。如果客户端没有禁用 Cookie,则 Cookie 在启动 Session 会话的时候扮演的是存储 Session ID 和 Session 生存期的角色!!!
cookie处理session id等参看:http://www.xiangdong.org/blog/post/1608/
众所周知,http协议是一个无状态协议,简单来说就是,web服务器是不知道现在连接上来的人到底是哪个人,为了满足选择性发送信息的需求,在http的基础上做了很多扩展来达到这个目的,如数字签名、cookie、session等。
web服务器或者web程序如何能够知道现在连接上来的是谁?要解决这个问题,首先需要在服务器端和客户端建立一一对应关系,下边我通过抓取http的内容来说明这种对应关系是如何建立的。
我使用的是一个叫做httplook的http包嗅探工具,然后在本地web服务器的根目录下建立一个叫test.php的文件,地址是:http://localhost/test.php,一切就绪以后我通过浏览器反复打开这个页面。
阅读全文
web服务器或者web程序如何能够知道现在连接上来的是谁?要解决这个问题,首先需要在服务器端和客户端建立一一对应关系,下边我通过抓取http的内容来说明这种对应关系是如何建立的。
我使用的是一个叫做httplook的http包嗅探工具,然后在本地web服务器的根目录下建立一个叫test.php的文件,地址是:http://localhost/test.php,一切就绪以后我通过浏览器反复打开这个页面。

Mysql Explain 详解
一.语法
explain < table_name >
例如: explain select * from t3 where id=3952602;
二.explain输出解释
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
1.id
我的理解是SQL执行的顺利的标识,SQL从大到小的执行.
例如:
mysql> explain select * from (select * from ( select * from t3 where id=3952602) a) b;
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
| 1 | PRIMARY | | system | NULL | NULL | NULL | NULL | 1 | |
| 2 | DERIVED | | system | NULL | NULL | NULL | NULL | 1 | |
| 3 | DERIVED | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | | 1 | |
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
很显然这条SQL是从里向外的执行,就是从id=3 向上执行.
阅读全文
一.语法
explain < table_name >
例如: explain select * from t3 where id=3952602;
二.explain输出解释
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
1.id
我的理解是SQL执行的顺利的标识,SQL从大到小的执行.
例如:
mysql> explain select * from (select * from ( select * from t3 where id=3952602) a) b;
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
| 1 | PRIMARY |
| 2 | DERIVED |
| 3 | DERIVED | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | | 1 | |
+----+-------------+------------+--------+-------------------+---------+---------+------+------+-------+
很显然这条SQL是从里向外的执行,就是从id=3 向上执行.

--post-file=文件 使用 POST 方法,发送指定文件中的内容。
剛剛看了一下 man wget, --post-file 參數並不是用來直接上傳檔案用的啦
必需要將上傳的資料先製作好放在檔案裡, 然後才用這個參數上傳
所以當我var dump(isset($_FILES))就判斷出$_FILES內有資料。但我現在就卡在我根本不知$_FILES內的資料內容為何
我有試過ricky大的建議用print_r($_FILES);
阅读全文
剛剛看了一下 man wget, --post-file 參數並不是用來直接上傳檔案用的啦
必需要將上傳的資料先製作好放在檔案裡, 然後才用這個參數上傳
所以當我var dump(isset($_FILES))就判斷出$_FILES內有資料。但我現在就卡在我根本不知$_FILES內的資料內容為何
我有試過ricky大的建議用print_r($_FILES);

strip_tags
去除html标签
This strips out markup tags, basically anything between < and >.
去除<和>标签,包括在<和>之间的任何内容.
Example 5-20. strip_tags
Smarty手册范例 5-20.去除Html标签
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|strip_tags}
输出结果:
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
去除html标签
This strips out markup tags, basically anything between < and >.
去除<和>标签,包括在<和>之间的任何内容.
Example 5-20. strip_tags
Smarty手册范例 5-20.去除Html标签
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|strip_tags}
输出结果:
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)。
原始例子:
$str = "Is your name O'reilly?";
// 输出:Is your name O\'reilly?
echo addslashes($str);
?>
<?php
function addslashes_array(&$ar)
{
if(is_array($ar)) {
foreach($ar as $key => $ar_sub) {
//$this->addslashes_array($ar[$key]);
addslashes_array($ar[$key]);
}
} else if(is_string($ar)) {
$ar = addslashes($ar);
}
}
?>
<?php
//数组情况
$addslashes_array = array("name"=>"xiangdong2","sex"=>"man","age"=>"24","address"=>"Is your name O'reilly?");
addslashes_array($addslashes_array);
var_dump($addslashes_array);
//字符串情况
$addslashes_string = "Is your name O'reilly?";
addslashes($addslashes_array);
echo $addslashes_string;
?>
function addslashes_array(&$ar)
{
if(is_array($ar)) {
foreach($ar as $key => $ar_sub) {
//$this->addslashes_array($ar[$key]);
addslashes_array($ar[$key]);
}
} else if(is_string($ar)) {
$ar = addslashes($ar);
}
}
?>
<?php
//数组情况
$addslashes_array = array("name"=>"xiangdong2","sex"=>"man","age"=>"24","address"=>"Is your name O'reilly?");
addslashes_array($addslashes_array);
var_dump($addslashes_array);
//字符串情况
$addslashes_string = "Is your name O'reilly?";
addslashes($addslashes_array);
echo $addslashes_string;
?>
原始例子:
$str = "Is your name O'reilly?";
// 输出:Is your name O\'reilly?
echo addslashes($str);
?>
is [not] odd是否为奇,
$a is not odd by $b即($a / $b) % 2 != 0 示例:
{if $smarty.section.outer.index is odd by 2}
odd英文是奇数的意思,也就是说这个能被2整除:
以上摘自smarty自己的demon。而odd则参考如下:
http://zjsky1989.blog.163.com/blog/static/8158784820134632416404/
{if $smarty.section.outer.index is odd by 1}
0 -1 * John
1 -2 . Mary
2 -3 * James
3 -4 . Henry
4 -5 * Tom
5 -6 . Hello
0/1=0 非奇非偶,执行else项
1/1=1 奇数,执行if项
2/1=2 偶数,执行else项
3/1=3 奇数,执行if项
4/1=4 偶数,执行else项
5/1=5 奇数,执行if项
来自:http://www.ithao123.cn/content-4326244.html
—————————————————————————————————————————
eq相等,
f7Y"Y f3m @,V+Z }4X0 ne、neq不相等,
7C E z R S8P t,i:@ ^0 gt大于,
阅读全文
$a is not odd by $b即($a / $b) % 2 != 0 示例:
{if $smarty.section.outer.index is odd by 2}
odd英文是奇数的意思,也就是说这个能被2整除:
以上摘自smarty自己的demon。而odd则参考如下:
http://zjsky1989.blog.163.com/blog/static/8158784820134632416404/
{if $smarty.section.outer.index is odd by 1}
0 -1 * John
1 -2 . Mary
2 -3 * James
3 -4 . Henry
4 -5 * Tom
5 -6 . Hello
0/1=0 非奇非偶,执行else项
1/1=1 奇数,执行if项
2/1=2 偶数,执行else项
3/1=3 奇数,执行if项
4/1=4 偶数,执行else项
5/1=5 奇数,执行if项
来自:http://www.ithao123.cn/content-4326244.html
—————————————————————————————————————————
eq相等,
f7Y"Y f3m @,V+Z }4X0 ne、neq不相等,
7C E z R S8P t,i:@ ^0 gt大于,

手机在待机情况下输入*7638#进如工程模式然后选择第二项硬件测试进去之后选择NANV格式第一,第二项应该就OK了
试下把
这歌叫哪里有我的家
MP3下载:
http://202.108.23.172/m?ct=134217728&tn=baidusg,影视插曲 哪里有我的家&word=mp3,http://www.beijing101.com/pts/song/影视插曲/9fbzIwgGBQrm9u8GNQ$$.mp3,,[%C4%C4%C0%EF%D3%D0%CE%D2%B5%C4%BC%D2]&si=;;;;0;;0&lm=16777216
试下把
这歌叫哪里有我的家
MP3下载:
http://202.108.23.172/m?ct=134217728&tn=baidusg,影视插曲 哪里有我的家&word=mp3,http://www.beijing101.com/pts/song/影视插曲/9fbzIwgGBQrm9u8GNQ$$.mp3,,[%C4%C4%C0%EF%D3%D0%CE%D2%B5%C4%BC%D2]&si=;;;;0;;0&lm=16777216
答案:
加上True即可!
结果:
stdClass Object
(
[code] => A00006
[data] => stdClass Object
(
[ uid] => stdClass Object
(
[relation] => 0
[gid] => 11
[stat] =>
)
)
)
加上True后:
Array
(
[code] => A00006
[data] => Array
(
[ uid] => Array
(
[relation] => 0
[gid] => 11
[stat] =>
)
)
)
参看:http://www.maycode.com/index.php/hotspot/32-web20/587-json.html
$json2array = json_decode($json,TRUE);
加上True即可!
<?php
$json = "{\"code\":\"A00006\",
\"data\":
{
\" uid\":
{
\"relation\":\"0\",
\"gid\": \"11\",
\"stat\" : \"\"
}
}
}";
$json2array = json_decode($json);
//$json2array = json_decode($json,TRUE);//这样foreach就没有该问题了
print_r($json2array);
?>
$json = "{\"code\":\"A00006\",
\"data\":
{
\" uid\":
{
\"relation\":\"0\",
\"gid\": \"11\",
\"stat\" : \"\"
}
}
}";
$json2array = json_decode($json);
//$json2array = json_decode($json,TRUE);//这样foreach就没有该问题了
print_r($json2array);
?>
结果:
stdClass Object
(
[code] => A00006
[data] => stdClass Object
(
[ uid] => stdClass Object
(
[relation] => 0
[gid] => 11
[stat] =>
)
)
)
加上True后:
Array
(
[code] => A00006
[data] => Array
(
[ uid] => Array
(
[relation] => 0
[gid] => 11
[stat] =>
)
)
)
参看:http://www.maycode.com/index.php/hotspot/32-web20/587-json.html
smarty 中foreach中iteration变量值就是当前循环次数
例子:
注意:得加上:name=name {$smarty.foreach.name.iteration} 依次循环会显示:1,2,3,4...
详细的例子如下:
HTML:
<html>
<head>
<title><{$title}></title>
</head>
<body>
<{$content}>
<{foreach from=$array item=foreach name=name}>
<{$foreach.newsID}><br>
<{$foreach.newsTitle}>
<h1>
<{$smarty.foreach.name.iteration}></h1><br>
<{/foreach}>
</body>
</html>
PHP:
main.php
例子:
<code>
{foreach key=key item=item from=$contact name=name}
{$key}: {$item}:{$smarty.foreach.name.iteration}<br>
{/foreach>
</code>
{foreach key=key item=item from=$contact name=name}
{$key}: {$item}:{$smarty.foreach.name.iteration}<br>
{/foreach>
</code>
注意:得加上:name=name {$smarty.foreach.name.iteration} 依次循环会显示:1,2,3,4...
详细的例子如下:
HTML:
<html>
<head>
<title><{$title}></title>
</head>
<body>
<{$content}>
<{foreach from=$array item=foreach name=name}>
<{$foreach.newsID}><br>
<{$foreach.newsTitle}>
<h1>
<{$smarty.foreach.name.iteration}></h1><br>
<{/foreach}>
</body>
</html>
PHP:
<?php
require "main.php";
$tpl->template_dir = "./aaa";
$array[] = array("newsID"=>1, "newsTitle"=>"第1条新闻");
$array[] = array("newsID"=>2, "newsTitle"=>"第2条新闻");
$array[] = array("newsID"=>3, "newsTitle"=>"第3条新闻");
$array[] = array("newsID"=>4, "newsTitle"=>"第4条新闻");
$array[] = array("newsID"=>5, "newsTitle"=>"第5条新闻");
$array[] = array("newsID"=>6, "newsTitle"=>"第6条新闻");
$tpl -> assign("array",$array);
$tpl -> assign("title","测试标题");
$tpl -> assign("content","Hello,World");
$tpl -> display("test.htm");
?>
require "main.php";
$tpl->template_dir = "./aaa";
$array[] = array("newsID"=>1, "newsTitle"=>"第1条新闻");
$array[] = array("newsID"=>2, "newsTitle"=>"第2条新闻");
$array[] = array("newsID"=>3, "newsTitle"=>"第3条新闻");
$array[] = array("newsID"=>4, "newsTitle"=>"第4条新闻");
$array[] = array("newsID"=>5, "newsTitle"=>"第5条新闻");
$array[] = array("newsID"=>6, "newsTitle"=>"第6条新闻");
$tpl -> assign("array",$array);
$tpl -> assign("title","测试标题");
$tpl -> assign("content","Hello,World");
$tpl -> display("test.htm");
?>
main.php
<?php
include "../drivers/smarty/Smarty.class.php";
$tpl= new Smarty();
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
?>
include "../drivers/smarty/Smarty.class.php";
$tpl= new Smarty();
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
?>
在 php.ini 配置文件里面有这个选项
disable_functions = ; This directive allows you to disable certain
; functions for security reasons. It receives
; a comma separated list of function names.
; This directive is *NOT* affected by whether
; Safe Mode is turned on or off.
改成
disble_functions = phpinfo
disable_functions = ; This directive allows you to disable certain
; functions for security reasons. It receives
; a comma separated list of function names.
; This directive is *NOT* affected by whether
; Safe Mode is turned on or off.
改成
disble_functions = phpinfo
公司说要启用我开发的电子考勤系统,本以为早测试过没有什么问题。。
一测试发现比实际时间慢了8个小时,晕死
实际是:2006-12-12 08:30:12
显示是:2006-12-12 00:30:12
算了算发现慢了8个小时,琢磨半天也不知道为啥子原因。。哈哈。。后来看了官方资料才醒悟了,默认系统时间是GMT时间
中国是GMT+8才是准确的。。
解决方法:
在php.ini里加上一句
date.timezone ="Etc/GMT-8"
随便加在那里,别加在第一行就行,哈哈
加好后,别忘记重启服务(IIS/APCHE)
请注意
如果没有修改php.ini的权限,那么应该在调用date()方法之前加上date_default_timezone_set(‘PRC’);
参数要加上双引号或单引号
修改php.ini时,
date.timezone = PRC
后面的参数不需要使用引号
摘自:http://www.cnblogs.com/martin1009/archive/2011/12/06/2277516.html
一测试发现比实际时间慢了8个小时,晕死
实际是:2006-12-12 08:30:12
显示是:2006-12-12 00:30:12
算了算发现慢了8个小时,琢磨半天也不知道为啥子原因。。哈哈。。后来看了官方资料才醒悟了,默认系统时间是GMT时间
中国是GMT+8才是准确的。。
解决方法:
在php.ini里加上一句
date.timezone ="Etc/GMT-8"
随便加在那里,别加在第一行就行,哈哈
加好后,别忘记重启服务(IIS/APCHE)
请注意
如果没有修改php.ini的权限,那么应该在调用date()方法之前加上date_default_timezone_set(‘PRC’);
参数要加上双引号或单引号
修改php.ini时,
date.timezone = PRC
后面的参数不需要使用引号
摘自:http://www.cnblogs.com/martin1009/archive/2011/12/06/2277516.html
instanceof 运算符是 PHP 5 引进的。在此之前用 is_a(),但是 is_a() 已经过时了,最好用 instanceof。
例子一:
<?php
class A { }
class B { }
$thing = new A;
if ($thing instanceof A) {
echo 'A';
}
if ($thing instanceof B) {
echo 'B';
}
?>
显示:A
例子二:
显示:AB
参看下面代码用到上面的例子二在: foreach($myCollection as $s) ----》 if($s instanceof Shape) //如果$s是Shape类的实例
阅读全文
例子一:
<?php
class A { }
class B { }
$thing = new A;
if ($thing instanceof A) {
echo 'A';
}
if ($thing instanceof B) {
echo 'B';
}
?>
显示:A
例子二:
<?php
abstract class A { }
abstract class B extends A{ }
class C extends B{}
$thing = new C;
if ($thing instanceof A) {
echo 'A';
}
if ($thing instanceof B) {
echo 'B';
}
?>
abstract class A { }
abstract class B extends A{ }
class C extends B{}
$thing = new C;
if ($thing instanceof A) {
echo 'A';
}
if ($thing instanceof B) {
echo 'B';
}
?>
显示:AB
参看下面代码用到上面的例子二在: foreach($myCollection as $s) ----》 if($s instanceof Shape) //如果$s是Shape类的实例

一、当你想选取一行的某一段给替换为你粘贴的那样的话,你可以先在命令行模式下按v,然后按w选中一个单词,然后按d删除即可,当然你也可以按j键向右选取你要选取的单词等。。。也可以按住ctril+$从下v的地方到行尾,同样可以按一下0,从下v的地方到行头喔,呵呵呵,j键盘和k键盘也是一样的可以选取多行在下v的地方上下选取,然后按一下d即可删除,再按v,然后粘贴你的内容进去即可。。。。。
二、光标在屏幕上部中间及下部的快捷操作法:
Shift + M :中间
Shift + H :顶部
Shift + L :下面
二、光标在屏幕上部中间及下部的快捷操作法:
Shift + M :中间
Shift + H :顶部
Shift + L :下面