當 php.ini 中的 magic_quotes_qpc 設定有開啟時

(magic_quotes_gpc = On) 當存入的資料中有 ' (單引號)會加入\(跳脫字元)

可以在程式碼中加入以下設定,避免這個情形發生


<?php
if (get_magic_quotes_gpc())
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_REQUEST = array_map('stripslashes', $_REQUEST);
}
?>時間加減

假設我要取得半年前的日期可以使用下面方式


<?php
$years = date("Y"); //用date()函式取得目前年份格式0000
$months = date("m"); //用date()函式取得目前月份格式00
$days = date("d"); //用date()函式取得目前日期格式00
$six_month_ago = date("Y-m-d",mktime(0,0,0,$months-6,$days,$years));
?>

想在網址中指定變數

import_request_variables('g', 'url_');
$url_a 就等於網址 http://demo.test.com/test.php?a=1

相关文章