<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Gets the current configuration setting of magic_quotes_gpc</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-loaded-extensions.html">get_loaded_extensions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-magic-quotes-runtime.html">get_magic_quotes_runtime</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.get-magic-quotes-gpc" class="refentry"> <div class="refnamediv"> <h1 class="refname">get_magic_quotes_gpc</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">get_magic_quotes_gpc</span> — <span class="dc-title">Gets the current configuration setting of magic_quotes_gpc</span></p> </div> <div class="refsect1 description" id="refsect1-function.get-magic-quotes-gpc-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>get_magic_quotes_gpc</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns the current configuration setting of <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a> </p> <p class="para"> Keep in mind that attempting to set <a href="info.configuration.html#ini.magic-quotes-gpc" class="link"> magic_quotes_gpc</a> at runtime will not work. </p> <p class="para"> For more information about magic_quotes, see this <a href="security.magicquotes.html" class="link">security section</a>. </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.get-magic-quotes-gpc-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns 0 if magic_quotes_gpc is off, 1 otherwise. Or always returns <strong><code>FALSE</code></strong> as of PHP 5.4.0. </p> </div> <div class="refsect1 changelog" id="refsect1-function.get-magic-quotes-gpc-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.4.0</td> <td> Always returns <strong><code>FALSE</code></strong> because the magic quotes feature was removed from PHP. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.get-magic-quotes-gpc-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-491"> <p><strong>Example #1 <span class="function"><strong>get_magic_quotes_gpc()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// If magic quotes are enabled<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">]; </span><span style="color: #FF8000">// O\'reilly<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">addslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">]); </span><span style="color: #FF8000">// O\\\'reilly<br /><br />// Usage across all PHP versions<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">get_magic_quotes_gpc</span><span style="color: #007700">()) {<br /> </span><span style="color: #0000BB">$lastname </span><span style="color: #007700">= </span><span style="color: #0000BB">stripslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">]);<br />}<br />else {<br /> </span><span style="color: #0000BB">$lastname </span><span style="color: #007700">= </span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">];<br />}<br /><br /></span><span style="color: #FF8000">// If using MySQL<br /></span><span style="color: #0000BB">$lastname </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_real_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$lastname</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$lastname</span><span style="color: #007700">; </span><span style="color: #FF8000">// O\'reilly<br /></span><span style="color: #0000BB">$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"INSERT INTO lastnames (lastname) VALUES ('</span><span style="color: #0000BB">$lastname</span><span style="color: #DD0000">')"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.get-magic-quotes-gpc-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If the directive <a href="sybase.configuration.html#ini.magic-quotes-sybase" class="link"> magic_quotes_sybase</a> is ON it will completely override <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a>. So even when <span class="function"><strong>get_magic_quotes_gpc()</strong></span> returns <strong><code>TRUE</code></strong> neither double quotes, backslashes or NUL's will be escaped. Only single quotes will be escaped. In this case they'll look like: <em class="emphasis">''</em> </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.get-magic-quotes-gpc-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.addslashes.html" class="function" rel="rdfs-seeAlso">addslashes()</a> - Quote string with slashes</span></li> <li class="member"> <span class="function"><a href="function.stripslashes.html" class="function" rel="rdfs-seeAlso">stripslashes()</a> - Un-quotes a quoted string</span></li> <li class="member"> <span class="function"><a href="function.get-magic-quotes-runtime.html" class="function" rel="rdfs-seeAlso">get_magic_quotes_runtime()</a> - Gets the current active configuration setting of magic_quotes_runtime</span></li> <li class="member"> <span class="function"><a href="function.ini-get.html" class="function" rel="rdfs-seeAlso">ini_get()</a> - Gets the value of a configuration option</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-loaded-extensions.html">get_loaded_extensions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-magic-quotes-runtime.html">get_magic_quotes_runtime</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>