{"id":769,"date":"2012-06-19T18:38:44","date_gmt":"2012-06-19T18:38:44","guid":{"rendered":"http:\/\/www.withinweb.com\/info\/?p=769"},"modified":"2012-06-19T18:39:04","modified_gmt":"2012-06-19T18:39:04","slug":"magic_quotes-addslashes-and-stripslashes-amd-php-6","status":"publish","type":"post","link":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/","title":{"rendered":"magic_quotes, addslashes(), and stripslashes() and PHP 6"},"content":{"rendered":"<p>magic_quotes_gpc, when on, automatically adds slashes to all GET\/POST\/COOKIE data so that you don\u2019t need to use addslashes() before using GET\/POST\/COOKIE data in MySQL queries, etc. (e.g. with magic_quotes_gpc OR addslashes(), I\u2019m becomes I\\\\\u2019m). Well, magic_quotes_gpc is no convenience and just complicates things!<\/p>\n<p>Since magic_quotes_gpc can be on or off, you don\u2019t know whether to use addslashes() or not. You don\u2019t want to use addslashes() when magic_quotes_gpc is on because you\u2019ll add too many slashes (e.g. I\u2019m becomes I\\\\\\\\\u2019m), which is bad. Use addslashes() if magic_quotes_gpc is off, and don\u2019t if it\u2019s on (you can find out its setting with get_magic_quotes_gpc()). But you can\u2019t use the same code all the time. One workaround is something such as:<\/p>\n<p>if (!get_magic_quotes_gpc()) { $txt = addslashes($txt);<\/p>\n<p>Using magic quotes has always been confusing and in PHP 6 they are apparantly going to remove it.\u00a0 So it is better to program your scripts without using get_magic_quotes_gpc at all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>magic_quotes_gpc, when on, automatically adds slashes to all GET\/POST\/COOKIE data so that you don\u2019t need to use addslashes() before using GET\/POST\/COOKIE data in MySQL queries, etc. (e.g. with magic_quotes_gpc OR addslashes(), I\u2019m becomes I\\\\\u2019m). Well, magic_quotes_gpc is no convenience and<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/\">Read more <span class=\"screen-reader-text\">magic_quotes, addslashes(), and stripslashes() and PHP 6<\/span><span class=\"meta-nav\"> &#8250;<\/span><\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,11],"tags":[],"class_list":["post-769","post","type-post","status-publish","format-standard","hentry","category-general-php","category-security-issues"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications<\/title>\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.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications\" \/>\n<meta property=\"og:description\" content=\"magic_quotes_gpc, when on, automatically adds slashes to all GET\/POST\/COOKIE data so that you don\u2019t need to use addslashes() before using GET\/POST\/COOKIE data in MySQL queries, etc. (e.g. with magic_quotes_gpc OR addslashes(), I\u2019m becomes I\\\u2019m). Well, magic_quotes_gpc is no convenience and&hellip;Read more magic_quotes, addslashes(), and stripslashes() and PHP 6 &#8250;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/\" \/>\n<meta property=\"og:site_name\" content=\"PHP Web Applications\" \/>\n<meta property=\"article:published_time\" content=\"2012-06-19T18:38:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-06-19T18:39:04+00:00\" \/>\n<meta name=\"author\" content=\"paulv\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"paulv\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/\"},\"author\":{\"name\":\"paulv\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"headline\":\"magic_quotes, addslashes(), and stripslashes() and PHP 6\",\"datePublished\":\"2012-06-19T18:38:44+00:00\",\"dateModified\":\"2012-06-19T18:39:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/\"},\"wordCount\":197,\"commentCount\":0,\"articleSection\":[\"General PHP\",\"Security Issues\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/\",\"name\":\"magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#website\"},\"datePublished\":\"2012-06-19T18:38:44+00:00\",\"dateModified\":\"2012-06-19T18:39:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/magic_quotes-addslashes-and-stripslashes-amd-php-6\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"magic_quotes, addslashes(), and stripslashes() and PHP 6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/\",\"name\":\"PHP Web Applications\",\"description\":\"Information and support for products of WithinWeb.com\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\",\"name\":\"paulv\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/author\\\/paulv\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications","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.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/","og_locale":"en_US","og_type":"article","og_title":"magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications","og_description":"magic_quotes_gpc, when on, automatically adds slashes to all GET\/POST\/COOKIE data so that you don\u2019t need to use addslashes() before using GET\/POST\/COOKIE data in MySQL queries, etc. (e.g. with magic_quotes_gpc OR addslashes(), I\u2019m becomes I\\\u2019m). Well, magic_quotes_gpc is no convenience and&hellip;Read more magic_quotes, addslashes(), and stripslashes() and PHP 6 &#8250;","og_url":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/","og_site_name":"PHP Web Applications","article_published_time":"2012-06-19T18:38:44+00:00","article_modified_time":"2012-06-19T18:39:04+00:00","author":"paulv","twitter_card":"summary_large_image","twitter_misc":{"Written by":"paulv","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/#article","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/"},"author":{"name":"paulv","@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"headline":"magic_quotes, addslashes(), and stripslashes() and PHP 6","datePublished":"2012-06-19T18:38:44+00:00","dateModified":"2012-06-19T18:39:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/"},"wordCount":197,"commentCount":0,"articleSection":["General PHP","Security Issues"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/","url":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/","name":"magic_quotes, addslashes(), and stripslashes() and PHP 6 - PHP Web Applications","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/#website"},"datePublished":"2012-06-19T18:38:44+00:00","dateModified":"2012-06-19T18:39:04+00:00","author":{"@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"breadcrumb":{"@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.withinweb.com\/info\/magic_quotes-addslashes-and-stripslashes-amd-php-6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.withinweb.com\/info\/"},{"@type":"ListItem","position":2,"name":"magic_quotes, addslashes(), and stripslashes() and PHP 6"}]},{"@type":"WebSite","@id":"https:\/\/www.withinweb.com\/info\/#website","url":"https:\/\/www.withinweb.com\/info\/","name":"PHP Web Applications","description":"Information and support for products of WithinWeb.com","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.withinweb.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c","name":"paulv","url":"https:\/\/www.withinweb.com\/info\/author\/paulv\/"}]}},"_links":{"self":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/comments?post=769"}],"version-history":[{"count":3,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/769\/revisions"}],"predecessor-version":[{"id":772,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/769\/revisions\/772"}],"wp:attachment":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/media?parent=769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/categories?post=769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/tags?post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}