标签: php
我正在尝试:print "This is my car number $this->attr['number'] ... \n";
print "This is my car number $this->attr['number'] ... \n";
但我收到此错误:Array to string conversion ...
Array to string conversion ...
如何解决此语法错误并使用"代替'?
"
'
答案 0 :(得分:4)
print "This is my car number {$this->attr['number']} ... \n";
将变量放在{}中可以解决您的问题,因为php将其评估为一个变量