{"id":10107,"date":"2020-02-07T12:25:45","date_gmt":"2020-02-07T12:25:45","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=10107"},"modified":"2022-05-08T12:07:20","modified_gmt":"2022-05-08T12:07:20","slug":"what-is-string-how-it-works-with-an-example-in-php","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-is-string-how-it-works-with-an-example-in-php\/","title":{"rendered":"How to define String in PHP?"},"content":{"rendered":"\n<p>A <strong>string <\/strong>is a group of characters, where a character is equivalent to a byte. This implies <strong>PHP<\/strong> just supports a 256-character set and subsequently doesn\u2019t offer local Unicode support.<br> <strong>ex:-<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"233\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/string.png\" alt=\"\" class=\"wp-image-10109\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/string.png 711w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/02\/string-300x98.png 300w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/figure>\n\n\n\n<p><strong>Single quote (&#8216;) :-<\/strong><\/p>\n\n\n\n<p><strong>Single quote<\/strong> <strong>strings <\/strong>are the most straightforward approach to indicate string. Single quote is utilized to indicate string when we need the string to be actually as it is composed.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/f036169e5f66c688b355ac34cf87afd2.js\"><\/script>\n\n\n\n<p>Here, used single quote string so not displayed or output your data value. Here work as a string. If you want to print correct data value then add in Double quote string.<\/p>\n\n\n\n<p><strong>Double quote (\u201c):-<\/strong><br>Double quoted strings are used to print any value of a variable in PHP. It will show a large group of got away characters, and variables in the strings will be assessed. A significant point here is that you can use curly braces to isolate the name of the variable you want to be evaluated.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/53c123c35181cdfc0fc5e54c4bfb358b.js\"><\/script>\n\n\n\n<p>Here, Double quote string uses to print or display variables of data.<\/p>\n\n\n\n<p><strong>Heredoc  (&lt;&lt;&lt;)<\/strong>:- It works similarly as the double quote.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/15d2b4e6c8b3e329a629264e610a2875.js\"><\/script>\n\n\n\n<p>Here, used heredoc syntax in this where (echo &lt;&lt;&lt; ANYDATA) then, right if  (echo &lt;&lt;&lt; ANYDATA ) you want to any space or any tab then show error.<\/p>\n\n\n\n<p><strong>Nowdoc (&lt;&lt;&lt;&#8216; &#8216;):- <\/strong>It works similarly as a single quote.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/ajcotocus\/f8ea3fed901fd8d84c7935fa6638914b.js\"><\/script>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_24328\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_96011\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_24328\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>A string is a group of characters, where a character is equivalent to a byte. This implies PHP just supports a 256-character set and subsequently doesn\u2019t offer local Unicode support. ex:- Single quote (&#8216;) :- Single quote strings are the most straightforward approach to indicate string. Single quote is utilized to indicate string when we&#8230;<\/p>\n","protected":false},"author":1,"featured_media":10115,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[5150],"tags":[5889,519,177,5887,466],"class_list":["post-10107","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-double-quote","tag-example","tag-php","tag-single-quote","tag-string"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=10107"}],"version-history":[{"count":12,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10107\/revisions"}],"predecessor-version":[{"id":24967,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/10107\/revisions\/24967"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/10115"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=10107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=10107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=10107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}