<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4560,"date":"2022-08-02T12:35:01","date_gmt":"2022-08-02T12:35:01","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4560"},"modified":"2022-08-02T12:35:01","modified_gmt":"2022-08-02T12:35:01","slug":"what-is-echo-and-print-in-php","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/","title":{"rendered":"What is echo and print in PHP ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">PHP is not a function; it is a language construct and its output become one or more string.<\/li>\n<li style=\"text-align: justify;\">If you want to pass more than one parameter to echo, the use of parentheses is required.<\/li>\n<li style=\"text-align: justify;\"><a href=\"https:\/\/www.wikitechy.com\/php\/php-echo\">PHP echo statement<\/a> is used to print the string, array, variable multi-line strings, escaping characters, etc.<\/li>\n<li style=\"text-align: justify;\">Echo is used to display the output, because it is a statement and does not return any value.<\/li>\n<li style=\"text-align: justify;\">Echo can be used with echo () or without parentheses echo.<\/li>\n<li style=\"text-align: justify;\">In echo, we can pass multiple strings separated by a comma (,).<\/li>\n<li style=\"text-align: justify;\">The <a href=\"https:\/\/www.wikitechy.com\/php\/php-print\">PHP print<\/a> can be used alternative to echo many times and its statement is similar to the echo statement.<\/li>\n<li style=\"text-align: justify;\">In PHP print accepts one argument at a time &amp; cannot be used as a variable function.<\/li>\n<li style=\"text-align: justify;\">Echo is faster than the print statement and print outputs only the strings.<\/li>\n<li style=\"text-align: justify;\">The main difference between the echo and print statement is that echo does not behave like function whereas print behave like a function.<\/li>\n<\/ul>\n<h2 id=\"sample-code-echo-statement\">Sample Code : Echo Statement<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-php code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-php code-embed-code\">&lt;!DOCTYPE html&gt;<br\/>&lt;html&gt;<br\/>&lt;body&gt;<br\/><br\/>&lt;?php<br\/>echo &quot;&lt;h2&gt;PHP is Fun!&lt;\/h2&gt;&quot;;<br\/>echo &quot;Welcome to wikitechy!&lt;br&gt;&quot;;<br\/>echo &quot;I&#039;m about to learn PHP!&lt;br&gt;&quot;;<br\/>echo &quot;This &quot;, &quot;string &quot;, &quot;was &quot;, &quot;made &quot;, &quot;with multiple parameters.&quot;;<br\/>?&gt; <br\/><br\/>&lt;\/body&gt;<br\/>&lt;\/html&gt;<\/code><\/pre> <\/div>\n<h2 id=\"output\">Output<img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4561\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png\" alt=\"\" width=\"1295\" height=\"596\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png 1295w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-300x138.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-1024x471.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-768x353.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-390x179.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-820x377.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement-1180x543.png 1180w\" sizes=\"(max-width: 1295px) 100vw, 1295px\" \/><\/h2>\n<h2 id=\"sample-code-print-statement\">Sample Code: Print Statement<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-php code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-php code-embed-code\">&lt;!DOCTYPE html&gt;<br\/>&lt;html&gt;<br\/>&lt;body&gt;<br\/><br\/>&lt;?php<br\/>$txt1 = &quot;Learn PHP&quot;;<br\/>$txt2 = &quot;Wikitechy.com&quot;;<br\/>$x = 5;<br\/>$y = 5;<br\/><br\/>print &quot;&lt;h2&gt;&quot; . $txt1 . &quot;&lt;\/h2&gt;&quot;;<br\/>print &quot;Study PHP at &quot; . $txt2 . &quot;&lt;br&gt;&quot;;<br\/>print $x + $y;<br\/>?&gt;<br\/><br\/>&lt;\/body&gt;<br\/>&lt;\/html&gt;<\/code><\/pre> <\/div>\n<h2 id=\"output-2\">Output<\/h2>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-4562\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement.png\" alt=\"\" width=\"1290\" height=\"629\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement.png 1290w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-300x146.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-1024x499.png 1024w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-768x374.png 768w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-390x190.png 390w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-820x400.png 820w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/print-statement-1180x575.png 1180w\" sizes=\"(max-width: 1290px) 100vw, 1290px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP is not a function; it is a language construct and its output become one or more string. If you want to pass more than one parameter to echo, the use of parentheses is required. PHP echo statement is used to print the string, array, variable multi-line strings, escaping characters, etc. Echo is used to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[8182],"tags":[17728,17723,17735,17725,17733,17726,17727,17729,17730,17734,17732,17731,17724,17736],"class_list":["post-4560","post","type-post","status-publish","format-standard","hentry","category-php","tag-difference-between-echo-and-print-in-php","tag-echo-and-print-difference-in-php","tag-echo-and-print-in-php","tag-echo-php-in-html","tag-example-of-echo-and-print-in-php","tag-php-echo-variable","tag-php-echo-variable-in-html","tag-php-print-array","tag-php-print-to-console","tag-what-are-the-differences-between-echo-and-print-in-php","tag-what-is-difference-between-echo-and-print_r-in-php","tag-what-is-echo-and-print-in-php","tag-what-is-print-in-php","tag-why-echo-is-faster-than-print-in-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is echo and print in PHP ? - PHP Echo and Print Statements<\/title>\n<meta name=\"description\" content=\"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.\" \/>\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.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is echo and print in PHP ? - PHP Echo and Print Statements\" \/>\n<meta property=\"og:description\" content=\"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-02T12:35:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/\",\"name\":\"What is echo and print in PHP ? - PHP Echo and Print Statements\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png\",\"datePublished\":\"2022-08-02T12:35:01+00:00\",\"dateModified\":\"2022-08-02T12:35:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png\",\"contentUrl\":\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png\",\"width\":1295,\"height\":596},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is echo and print in PHP ? - PHP Echo and Print Statements","description":"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.","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.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/","og_locale":"en_US","og_type":"article","og_title":"What is echo and print in PHP ? - PHP Echo and Print Statements","og_description":"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/","og_site_name":"Wikitechy","article_published_time":"2022-08-02T12:35:01+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png"}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/","name":"What is echo and print in PHP ? - PHP Echo and Print Statements","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png","datePublished":"2022-08-02T12:35:01+00:00","dateModified":"2022-08-02T12:35:01+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is echo and print in PHP ? - PHP is not a function; it is a language construct and its output become one or more string.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/php\/what-is-echo-and-print-in-php\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/echo-statement.png","width":1295,"height":596},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4560"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4560\/revisions"}],"predecessor-version":[{"id":4563,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4560\/revisions\/4563"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}