Created
April 12, 2011 09:50
-
-
Save sunny/915263 to your computer and use it in GitHub Desktop.
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
| <? | |
| // Crée un fichier à partir d'un string, retourne le path complet vers le nouveau fichier | |
| function create_file_from_string($string, $filename) { | |
| $filename = LIB_PATH . '/tmp/' . $filename; | |
| $handle = @fopen($filename, 'w+'); | |
| if (!$handle) | |
| throw new Exception(sprintf(_("Impossible d'ouvrir le fichier %s en écriture !"), $filename)); | |
| if ($string) { | |
| $ok = @fwrite($handle, $string); | |
| if (!$ok) { | |
| @fclose($handle); | |
| new Exception(sprintf(_("Impossible d'écrire dans le fichier %s !"), $filename)); | |
| } | |
| } | |
| fclose($handle); | |
| return $filename; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment