欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php 双引号里面的解析

程序员文章站 2022-03-31 17:38:47
...
echo"This works: {$arr['foo'][3]}";
echo"This works too: {$obj->values[3]->name}";
echo"This is the value of the var named $name: {${$name}}";
echo"value of the var named by the return value of getName(): {${getName()}}";
echo"value of the var named by the return value of \$object->getName(): {${$object->getName()}}";

解析数组

$juices = array("apple", "orange", "koolaid1" => "purple");
echo"He drank some $juices[0] juice.".PHP_EOL;
echo"He drank some $juices[koolaid1] juice.".PHP_EOL;
// 有效,只有通过花括号语法才能正确解析带引号的键名
echo"This works: {$arr['key']}";
// 有效
echo"This works: {$arr[4][3]}";

解析变量

echo"This is {$great}";
echo"This is ${great}";

输出字符串

$a = 'aaaa';
$c['c'] = "ccc";
$b = "i am '$a' and  '$c[c]' \" 我是双引号!\"";
echo$b; //i am 'aaaa' and 'ccc'" 我是双引号!"

{}的解析

classbeers {const softdrink = 'rootbeer';
    publicstatic$ale = 'ipa';
}
$rootbeer = 'A & W';
$ipa = 'Alexander Keith\'s';
// 有效,输出: I'd like an A & Wecho"I'd like an {${beers::softdrink}}\n";
// 也有效,输出: I'd like an Alexander Keith'secho"I'd like an {${beers::$ale}}\n";

解析对象

// 有效
echo "This square is {$square->width}00 centimeters broad.";

版权声明:知识取之于民,用之于民!欢迎转载,转载请开头附上本文链接,不定期更新文章!

以上就介绍了php 双引号里面的解析,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

php 双引号里面的解析

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频