11 标量插入串(Llama书的第二章) |
|
- 我们能在字符串中使用标量变量:
- $h="World";$hw="Hello $h";#设置$hw为"Hello
World".
- $h="World";$hw="\UHello $h";#设置$hw为"HELLO
WORLD".
- 表明\U和类似的\L怎样在插入变量中操作.
- 就象上面提到的,对于单引号字符串没有插入.
- 也没有递归插入,象下面的解释:
- $fred="Wou over there"; $x='$fred';$y="Hey $x";#设置$y为"Hey
$fred",而没有插入.
- 使用\$,以保证在你真正需要$字符的地方没有插入:
- $fred="You over there";$y="Hey \$fred";#设置$y为"Hey
$fred",并没有插入.
- $fred="You over there";$y="Hey $fred";#设置$y为"Hey
You over there",使用了插入.
Copyright: NPACT |
|