PHP
downloads | documentation | faq | getting help | mailing lists | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Cookies> <PHP 3 扩展
Last updated: Sun, 25 Nov 2007

view this page in

字符串中的变量替换

PHP 4 添加了一个新的机制以替换字符串中的变量。现在可以访问字符串中的对象成员变量和多维数组元素。

如果想这么做,需要使用大括号将一个美元符号和变量名括起来,就像这样:{$...}

要在字符串中嵌入对象成员变量,只要简单的写 "text {$obj->member} text"。而在 PHP 3 中,要使用 "text ".$obj->member." text"

这个改进可以使代码更易读,但这可能会破坏用 PHP 3 写的代码。但是很容易修正它:在代码中查找字符串中的 {$,使用搜索替换工具将它替换为 \{$



add a note add a note User Contributed Notes
字符串中的变量替换
There are no user contributed notes for this page.

Cookies> <PHP 3 扩展
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites