Created
May 14, 2012 06:31
-
-
Save s-hiroshi/2692173 to your computer and use it in GitHub Desktop.
PHP > create file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * create file | |
| */ | |
| function createFile($dir, $file) { | |
| $html = <<<HTML | |
| <!DOCTYPE HTML>'; | |
| <html lang="en">'; | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <p>file create template.</p> | |
| </body> | |
| </html> | |
| HTML; | |
| $html = mb_convert_encoding($html, "UTF-8"); | |
| // ファイル出力処理 | |
| $direcName = $dir; | |
| $fileName = $file; | |
| $filePath = $direcName . $fileName; | |
| $fp = fopen($filePath, "w") or die("can not open file."); | |
| flock($fp, LOCK_EX); | |
| fputs($fp, $html); | |
| flock($fp, LOCK_UN); | |
| fclose($fp); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment