您好,我希望使用Preg_Replace函數,只要我檢查輸入的用戶是否輸入任何值。如果沒有給出這樣的錯誤消息「請輸入你的名字嗎」,但不是這個我收到此錯誤:Preg_Replace在空值中給出錯誤
公告:未定義指數:用C buildingslabs:\ XAMPP \ htdocs中\ spdealers \管理員
面板\ Property_Insert_Page_exe.php上線24
這裏是我的代碼:
<?php
$buildingslabs = preg_replace("[^A-Z a-z0-9]", "", $_POST['buildingslabs']);
if(empty($buildingslabs)
{
echo 'Plese Enter the Buildings Labs';
}
else
{
echo 'successfully inserted';
}
?>
你應該總是對'Post'和'Get'值使用'isset',然後檢查它們是否爲'empty' – 2013-04-10 04:30:27