[英]Recursive browse all server directories and list newest created files with php
[英]PHP Error - All Files or Directories created are 0
我最近正在編寫一個注冊腳本,並想在另一個名為“用戶”的文件夾中創建一個文件夾。 不知何故,創建的文件夾位於根路徑(php腳本所在的位置)中,並且應該寫在該文件夾中的文件位於名為0的文件中。以下是代碼:
if (!isset($_POST["method"])){
die("Error");
}
if (!isset($_POST["usernamefld"])){
die("Error");
}
if (!isset($_POST["passwordfld"])){
die("Error");
}
if ($_POST["method"] == "register"){
if (!isset($_POST["emailfld"])){
die("Error");
}
if(is_dir("./users/"+$_POST["usernamefld"])){
die("Taken");
}
mkdir("/users/"+$_POST["usernamefld"]);
echo "test";
}
文件夾“ 0”在創建時始終為空。
正如@u_mulder所說的,在PHP中,我們用“。”連接字符串和變量。 而不是“ +”符號。 基於此,這應該有助於解決您的特定問題。
if (!isset($_POST["method"])){
die("Error");
}
if (!isset($_POST["usernamefld"])){
die("Error");
}
if (!isset($_POST["passwordfld"])){
die("Error");
}
if ($_POST["method"] == "register"){
if (!isset($_POST["emailfld"])){
die("Error");
}
if(is_dir("./users/". $_POST["usernamefld"])){
die("Taken");
}
mkdir("/users/". $_POST["usernamefld"]);
echo "test";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.