Home / PHP Tips Generated By ChatGPT / Creating a Directory in PHP Use mkdir() to create a new directory. Source Code if (!file_exists('path/to/directory')) { mkdir('path/to/directory', 0777, true); echo "Directory created."; }