Something like this. Without the file part.
// ## Define dir to make ##
$newdir = "/home/apache/htdocs/text";
// ## Check to see if dir exists
if (file_exists($newdir)) die("Error");
// ## If not; Create dir with chmod
mkdir ($newdir, 0777);
// ## CHMOD a dir ##
chmod ($newdir, 0755);