What is the advantage of using Heredoc in PHP? [closed]
问题 What is the advantage of using Heredoc in PHP, and can you show an example? 回答1: The here doc syntax is much cleaner to me and it is really useful for multi-line strings and avoiding quoting issues. Back in the day I used to use them to construct SQL queries: $sql = <<<SQL select * from $tablename where id in [$order_ids_list] and product_name = "widgets" SQL; To me this has a lower probability of introducing a syntax error than using quotes: $sql = " select * from $tablename where id in [