猿问
PHP中的字符串大括号
PHP中的字符串大括号
何谓
{ }
(大括号)用PHP中的字符串字面值表示?
慕桂英546537
浏览 725
回答 3
3回答
函数式编程
对我来说,花括号是连接的替代物,它们是更快类型和代码看起来更干净。记住使用双引号(“)作为内容解析,因为在单引号(‘)中,您将得到文字名称变量数,但须:<?php $a = '12345';// This works: echo "qwe{$a}rty"; // qwe12345rty, using braces echo "qwe" . $a . "rty"; // qwe12345rty, concatenation used// Does not work: echo 'qwe{$a}rty'; // qwe{$a}rty, single quotes are not parsed echo "qwe$arty"; // qwe, because $a became $arty, which is undefined?>
0
0
0
MM们
例子:$number = 4;print "You have the {$number}th edition book";//output: "You have the 4th edition book";如果没有大括号,PHP将试图找到一个名为$numberth那是不存在的!
0
0
0
随时随地看视频
慕课网APP
相关分类
PHP
php如何把参数放在Http Request Heade????
1 回答
我要回答