小编Tox*_*xic的帖子

PHP双括号字符串中的括号

这更像是一种更好的练习类型的问题.

我想知道在变量的双引号字符串中使用括号是否是一种好习惯.

例如:

<?php
$Variable = 'a variable';
$SingleQuotedString = 'Single quoted string with ' . $Variable;
// Single quoted string with a variable

$DoubleQuotedString = "Double quoted string with $Variable";
// Double quoted string with a variable

$DoubleQuotedStringWithBrackets = "Double quoted string with {$Variable} in brackets.";
// Double quoted string with a variable in brackets.
?>
Run Code Online (Sandbox Code Playgroud)

它不会改变简单测试的输出或代码,显然有效.我只是感到困惑,因为没有多少人这样做,我没有看到建议或人们不同意,我一直在使用它们.

感谢您的任何反馈!

php string

1
推荐指数
2
解决办法
1743
查看次数

标签 统计

php ×1

string ×1