{"id":821,"date":"2012-07-03T09:46:45","date_gmt":"2012-07-03T09:46:45","guid":{"rendered":"http:\/\/www.withinweb.com\/info\/?p=821"},"modified":"2012-09-20T08:11:40","modified_gmt":"2012-09-20T08:11:40","slug":"get_magic_quotes_gpc-in-php6","status":"publish","type":"post","link":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/","title":{"rendered":"get_magic_quotes_gpc in PHP6"},"content":{"rendered":"<p>In PHP6, get_magic_qu0tes_gpc will be depreciated, but you may still want to be able to test for it if you do not know which version of PHP it will be running on.<\/p>\n<p>Here are two possible ways of how this might be done.\u00a0 Both of these create a new function called is_get_magic_quotes_gpc to make it easier to search and replace in a number of files.<\/p>\n<p>First method :<\/p>\n<blockquote><p>&lt;?php<\/p>\n<p>\/**<br \/>\nReturns true if have to make allowances for magic quotes or not<br \/>\nReturns true if magic quotes are on false otherwise<br \/>\nTest which version of PHP you have and make allowences as appropriate<br \/>\n**\/<br \/>\nfunction is_get_magic_quotes_gpc() {<\/p>\n<p>if ( version_compare(phpversion(), &#8216;6&#8217;, &#8216;&lt;&#8216;) ) {<\/p>\n<p>if ( get_magic_quotes_gpc() ) {<br \/>\nreturn true;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>}<br \/>\n?&gt;<\/p><\/blockquote>\n<p>Second method :<\/p>\n<blockquote><p>&lt;?php<\/p>\n<p>\/**<br \/>\nReturns true if have to make allowances for magic quotes or not<br \/>\nReturns true if magic quotes are on false otherwise<br \/>\nTest if the function exists or not and then make allowances as appropriate<br \/>\n**\/<br \/>\nfunction is_get_magic_quotes_gpc() {<\/p>\n<p>if ( function_exists(&#8220;get_magic_quotes_gpc&#8221;) )<br \/>\n{<br \/>\nif ( get_magic_quotes_gpc() ) {<br \/>\nreturn true;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>}<\/p>\n<p>?&gt;<\/p><\/blockquote>\n<p>Both of these can be tested using :<\/p>\n<blockquote><p>&lt;?php<\/p>\n<p>if ( is_get_magic_quotes_gpc() ) {<br \/>\necho(&#8220;yes&#8221;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\necho(&#8220;no&#8221;);<br \/>\n}<\/p>\n<p>echo(&#8220;&lt;p&gt;php version : &#8221; . phpversion() . &#8220;&lt;\/p&gt;&#8221;);<\/p>\n<p>?&gt;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In PHP6, get_magic_qu0tes_gpc will be depreciated, but you may still want to be able to test for it if you do not know which version of PHP it will be running on. Here are two possible ways of how this<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/\">Read more <span class=\"screen-reader-text\">get_magic_quotes_gpc in PHP6<\/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],"tags":[],"class_list":["post-821","post","type-post","status-publish","format-standard","hentry","category-general-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>get_magic_quotes_gpc in PHP6 - 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\/get_magic_quotes_gpc-in-php6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"get_magic_quotes_gpc in PHP6 - PHP Web Applications\" \/>\n<meta property=\"og:description\" content=\"In PHP6, get_magic_qu0tes_gpc will be depreciated, but you may still want to be able to test for it if you do not know which version of PHP it will be running on. Here are two possible ways of how this&hellip;Read more get_magic_quotes_gpc in PHP6 &#8250;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/\" \/>\n<meta property=\"og:site_name\" content=\"PHP Web Applications\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-03T09:46:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-09-20T08:11:40+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\\\/get_magic_quotes_gpc-in-php6\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/\"},\"author\":{\"name\":\"paulv\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"headline\":\"get_magic_quotes_gpc in PHP6\",\"datePublished\":\"2012-07-03T09:46:45+00:00\",\"dateModified\":\"2012-09-20T08:11:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/\"},\"wordCount\":237,\"commentCount\":0,\"articleSection\":[\"General PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/\",\"url\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/\",\"name\":\"get_magic_quotes_gpc in PHP6 - PHP Web Applications\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#website\"},\"datePublished\":\"2012-07-03T09:46:45+00:00\",\"dateModified\":\"2012-09-20T08:11:40+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/#\\\/schema\\\/person\\\/04da5531c302d55ffcd777fe81dbb93c\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/get_magic_quotes_gpc-in-php6\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.withinweb.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"get_magic_quotes_gpc in PHP6\"}]},{\"@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":"get_magic_quotes_gpc in PHP6 - 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\/get_magic_quotes_gpc-in-php6\/","og_locale":"en_US","og_type":"article","og_title":"get_magic_quotes_gpc in PHP6 - PHP Web Applications","og_description":"In PHP6, get_magic_qu0tes_gpc will be depreciated, but you may still want to be able to test for it if you do not know which version of PHP it will be running on. Here are two possible ways of how this&hellip;Read more get_magic_quotes_gpc in PHP6 &#8250;","og_url":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/","og_site_name":"PHP Web Applications","article_published_time":"2012-07-03T09:46:45+00:00","article_modified_time":"2012-09-20T08:11:40+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\/get_magic_quotes_gpc-in-php6\/#article","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/"},"author":{"name":"paulv","@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"headline":"get_magic_quotes_gpc in PHP6","datePublished":"2012-07-03T09:46:45+00:00","dateModified":"2012-09-20T08:11:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/"},"wordCount":237,"commentCount":0,"articleSection":["General PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/","url":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/","name":"get_magic_quotes_gpc in PHP6 - PHP Web Applications","isPartOf":{"@id":"https:\/\/www.withinweb.com\/info\/#website"},"datePublished":"2012-07-03T09:46:45+00:00","dateModified":"2012-09-20T08:11:40+00:00","author":{"@id":"https:\/\/www.withinweb.com\/info\/#\/schema\/person\/04da5531c302d55ffcd777fe81dbb93c"},"breadcrumb":{"@id":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.withinweb.com\/info\/get_magic_quotes_gpc-in-php6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.withinweb.com\/info\/"},{"@type":"ListItem","position":2,"name":"get_magic_quotes_gpc in PHP6"}]},{"@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\/821","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=821"}],"version-history":[{"count":8,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/821\/revisions"}],"predecessor-version":[{"id":827,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/posts\/821\/revisions\/827"}],"wp:attachment":[{"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/media?parent=821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/categories?post=821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withinweb.com\/info\/wp-json\/wp\/v2\/tags?post=821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}