{"id":30227,"date":"2023-03-19T17:31:38","date_gmt":"2023-10-09T01:08:17","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/"},"modified":"2025-08-12T18:11:15","modified_gmt":"2025-08-12T10:11:15","slug":"php%e4%b8%ad%e7%9a%84heredoc","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/","title":{"rendered":"PHP\u4e2d\u7684Heredoc"},"content":{"rendered":"<p>\u4f7f\u7528 Here Document \u6765\u8868\u793a\u8f83\u957f\u7684\u6587\u7ae0\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?php<\/span>\r\n\r\n<span class=\"nv\">$name<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">'kana'<\/span><span class=\"p\">;<\/span>\r\n<span class=\"nv\">$text<\/span> <span class=\"o\">=<\/span> <span class=\"sh\">&lt;&lt;&lt;EOT\r\n   \u3053\u3093\u306b\u3061\u306f\u3000$name\r\n   \u4eca\u65e5\u306f\u5929\u6c17\u826f\u3044\u306d\uff01\r\n\u307b\u3089\uff01\r\n\r\nEOT;<\/span> \r\n\r\n<span class=\"k\">echo<\/span> <span class=\"nv\">$text<\/span><span class=\"p\">;<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u7ec8\u7aef\u4e0a\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff01<\/p>\n<pre class=\"post-pre\"><code>~$ php index.php\r\n<\/code><\/pre>\n<p>\u8fd9\u5c06\u5728\u7ec8\u7aef\u4e0a\u8f93\u51fa\u5982\u4e0b\uff01<\/p>\n<pre class=\"post-pre\"><code>~$ php index.php\r\n   \u3053\u3093\u306b\u3061\u306f\u3000kana\r\n   \u4eca\u65e5\u306f\u5929\u6c17\u826f\u3044\u306d\uff01\r\n\u307b\u3089\uff01\r\n~ $ \r\n\r\n<\/code><\/pre>\n<p>\u6211\u80fd\u591f\u8f7b\u677e\u5730\u8fdb\u884c\u6362\u884c\u548c\u7f29\u8fdb\u2606<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 Here Document \u6765\u8868\u793a\u8f83\u957f\u7684\u6587\u7ae0\u3002 &lt;?php $name = &#8216;kana&#8217;; $te [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[227],"class_list":["post-30227","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP\u4e2d\u7684Heredoc - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/php\u4e2d\u7684heredoc\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP\u4e2d\u7684Heredoc\" \/>\n<meta property=\"og:description\" content=\"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/php\u4e2d\u7684heredoc\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-09T01:08:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-12T10:11:15+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/\",\"name\":\"PHP\u4e2d\u7684Heredoc - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-09T01:08:17+00:00\",\"dateModified\":\"2025-08-12T10:11:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"description\":\"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\u4e2d\u7684Heredoc\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"PHP\u4e2d\u7684Heredoc - Blog - Silicon Cloud","description":"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/php\u4e2d\u7684heredoc\/","og_locale":"zh_CN","og_type":"article","og_title":"PHP\u4e2d\u7684Heredoc","og_description":"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/php\u4e2d\u7684heredoc\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-09T01:08:17+00:00","article_modified_time":"2025-08-12T10:11:15+00:00","author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/","name":"PHP\u4e2d\u7684Heredoc - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-09T01:08:17+00:00","dateModified":"2025-08-12T10:11:15+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"description":"\u5173\u4e8ePHP\u4e2d\u7684Heredoc\u7684\u6280\u672f\u6587\u7ae0","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"PHP\u4e2d\u7684Heredoc"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/php%e4%b8%ad%e7%9a%84heredoc\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=30227"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30227\/revisions"}],"predecessor-version":[{"id":87235,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/30227\/revisions\/87235"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=30227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=30227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=30227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}