如:
================================================== 至少便于阅读嘛~~~''是insert into语句要求的,因为字符串要成对出现嘛加{}有时候是为了防止变量名和后面的字符串连在一起嘛 例如 {$cid}dd 如果cid=aa 那么{$cid}dd=aadd 不加的话你自己看看了$ciddd,岂不变成了ciddd变量了~~
// The following is okay as it's inside a string. Constants are not // looked for within strings so no E_NOTICE error here print "Hello $arr[fruit]"; // Hello apple // With one exception, braces surrounding arrays within strings // allows constants to be looked for print "Hello {$arr[fruit]}"; // Hello carrot 例如: $str = 'hello'; echo $str{0}; // 输出为 h echo $str{1}; // 输出为 e 如果要检查某个字符串是否满足多少长度,可以考虑用这种大括号(花括号)加 isset 的方式替代 strlen 函数,因为 isset 是语言结构,strlen 是函数,所以使用 isset 比使用 strlen 效率更高。 比如判断一个字符串的长度是否小于 5: if ( !isset ( $str{5} ) ) 就比 if ( strlen ( $str ) < 5 ) 好。 下面几个比较能说明原因的解释是:
表示{}里面的是一个变量 ,执行时按照变量来处理 其实输出那块是等同于print "hello ".$arr['fruit']; |
欢迎光临 就爱编程论坛 (http://bbs.waibc.com/) | Powered by Discuz! X2 |