{"id":697,"date":"2014-06-25T10:24:37","date_gmt":"2014-06-25T10:24:37","guid":{"rendered":"http:\/\/blog.silverterra.net\/?p=697"},"modified":"2024-12-08T19:29:44","modified_gmt":"2024-12-08T19:29:44","slug":"php-multiline-strings-in-the-code","status":"publish","type":"post","link":"https:\/\/blog.silverterra.net\/?p=697","title":{"rendered":"php multiline strings in the code"},"content":{"rendered":"<blockquote><p>Goal: use multiline strings in the code<\/p><\/blockquote>\n<p>I have a simple select statement. I want to store it in a variable but I want to forget the concatenation.<br \/>\nWe can use the <b>heredoc syntax<\/b>.<\/p>\n<pre><code>\r\n  $query = <<&lt;TEXT\r\n    select a.*\r\n    FROM (\r\n    select count(*) cnt, s.thunder thd, s.version ver\r\n    from ta_my_stat s\r\n    group by 2, 3\r\n    ) a\r\n    order by 1 desc, 2 asc;\r\nTEXT;\r\n<\/code><\/pre>\n<p>Only one restriction! In the last line we can put only the closer tag <b>TEXT;<\/b> with semicolon. No space, tab or other characters accepted before and after of that!<\/p>\n<blockquote><p>see also: <a href=\"http:\/\/php.net\/manual\/en\/language.types.string.php\" target=\"_blank\" rel=\"noopener\">about strings in php<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Goal: use multiline strings in the code I have a simple select statement. I want to store it in a variable but I want to forget the concatenation. We can use the heredoc syntax. $query =<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=697"}],"version-history":[{"count":26,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":1185,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions\/1185"}],"wp:attachment":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}