Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 echo 语句中打印 $book->author。现在我正在使用连接。
echo "book author: " . $book->author . "<br />";
如何将整个内容包含在双引号中?如果我执行以下操作,则假定我正在尝试回显该$book对象并且这->author是一个常规字符串。
$book
->author
echo "book author: $book->author<br />";
用花括号把它包起来。
echo "book author: {$book->author}<br />";
顺便说一句,我是以下内容的倡导者。我发现它读起来更好,克服了花括号方法的限制,并且是对字符串连接的微、微优化(见评论)。
echo "book author: ", $book->author, "<br />";