{"id":148,"date":"2016-07-06T14:06:29","date_gmt":"2016-07-06T14:06:29","guid":{"rendered":"https:\/\/barkhane.com\/php\/2016\/07\/06\/escape-characters-php\/"},"modified":"2024-03-03T15:05:00","modified_gmt":"2024-03-03T15:05:00","slug":"escape-characters-php","status":"publish","type":"post","link":"https:\/\/barkhane.com\/php\/escape-characters-php\/","title":{"rendered":"Escape Characters PHP"},"content":{"rendered":"<h2>What are Escape sequence in PHP ?<\/h2>\n<p>Escape sequences is the combination of the escape character<strong> \\&#8217;\\\\\\&#8217;<\/strong> and a letter, are used to signify that the character after the escape character should be treated specially. if you wanted to have the string in which \\&#8221;or \\&#8217; or $ should be printed then , you would need escape characters because you have double quotes inside double quotes.And if we do not want to <a href=\"https:\/\/barkhane.com\/php\/interpolation\/\" target=\"_blank\" rel=\"noopener\">interpolate <\/a>our string then we have to use Escape sequences\u00a0Here is a list of the escape sequences in <a href=\"https:\/\/barkhane.com\/php\/what-is-php\/\" target=\"_blank\" rel=\"noopener\">PHP<\/a>:<\/p>\n<blockquote><p>&nbsp;<\/p>\n<ol>\n<li><strong>\\\\\\&#8221;<\/strong>&#8211; \u00a0Print the next character as a double quote.<\/li>\n<li><strong>\\\\\\&#8217;<\/strong>&#8211; \u00a0\u00a0Print the next character as a single quote.<\/li>\n<li><strong>\\\\n<\/strong>&#8211; Print a new line character (not always supported\u00a0)<\/li>\n<li><strong>\\\\t<\/strong>&#8211; \u00a0Print a tab character.<\/li>\n<li><strong>\\\\r<\/strong>&#8211; \u00a0Print a carriage return (not used very often).<\/li>\n<li><strong>\\\\$<\/strong>&#8211; Print the next character as a dollar.<\/li>\n<li>\u00a0<strong>\\\\\\\\<\/strong>&#8211;\u00a0Print the next character as a backslash, <strong>not an escape character.<\/strong>Now if you want to print address of a file then you can write it like<br \/>\n<span class=\"hljs-variable\">$MyFile<\/span> = <span class=\"hljs-string\">\\&#8221;<strong>c:\\\\\\\\new\\\\\\\\folder1\\\\\\\\hello.txt<\/strong>\\&#8221;<\/span>;<br \/>\necho \u00a0$MyFile; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\/\/output will be\u00a0<strong>c:\\\\new\\\\folder1\\\\hello.txt<\/strong><\/li>\n<\/ol>\n<\/blockquote>\n<p>Escape sequences are very important in display and handling data on server because there are various characters which are reserve in <a href=\"https:\/\/barkhane.com\/php\/what-is-php\/\" target=\"_blank\" rel=\"noopener\">php <\/a>and if we want it into report then have to use\u00a0Escape sequences.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What are Escape sequence in PHP ? Escape sequences is the combination of the escape character \\&#8217;\\\\\\&#8217; and a letter, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":0,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barkhane.com\/php\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}