Php/docs/function.get-magic-quotes-gpc

提供:Dev Guides
< Php
移動先:案内検索

get_magic_quotes_gpc

(PHP 4, PHP 5, PHP 7)

get_magic_quotes_gpcmagic_quotes_gpc の現在の設定を得る


警告 この関数は PHP 7.4.0 で 非推奨になります。この関数に頼らないことを強く推奨します。


説明

get_magic_quotes_gpc ( ) : bool

magic_quotes_gpc の現在の設定を返します。

実行時に magic_quotes_gpc をセットしようとしても反映されないことに留意してください。

magic_quotes についての詳細な情報は セキュリティの欄 を参照してください。


返り値

magic_quotes_gpc がオフの場合に 0、そうでない場合に 1 を返します。 PHP 5.4.0 以降は、常に false を返します。


変更履歴

バージョン 説明
7.4.0 この関数は推奨されなくなりました。


例1 get_magic_quotes_gpc() の例

<?phpecho get_magic_quotes_gpc();         // 1echo $_POST['lastname'];             // O\'reillyecho addslashes($_POST['lastname']); // O\\\'reillyif (get_magic_quotes_gpc()) {    $lastname = stripslashes($_POST['lastname']);}else {    $lastname = $_POST['lastname'];}// MySQL を使っている場合$lastname = mysql_real_escape_string($lastname);echo $lastname; // O\'reilly$sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')";?>

参考