Christopher
Christopher

Reputation: 3469

PHP - Print array variable gives error

I'm trying this: print "This is my car number $this->attr['number'] ... \n";

But i get this error: Array to string conversion ...

How can i solve this syntax error and use " instead of '?

Upvotes: 0

Views: 50

Answers (1)

Pudotta Pommin
Pudotta Pommin

Reputation: 66

print "This is my car number {$this->attr['number']} ... \n";

Putting variable in {} should solve your problem, because php evaluate it as one variable

Upvotes: 4

Related Questions