Home >php教程 >php手册 >当PHP被禁用的PHP函数:tempnam() 后

当PHP被禁用的PHP函数:tempnam() 后

WBOY
WBOYOriginal
2016-06-21 08:59:13767browse
  当PHP被禁用的PHP函数:tempnam() 后,tempnam()可建立一个临时档,档名不会与同目录中的档案重覆。

  传回字串就是建立的临时档名。若发生错误则传回空字串。
 
  而smarty运行就必须在类似templates_c的设置编译目录,然后运行后它会自动创建类似%%

  43^43B^43B32F4B%%index.htm.php的临时档,所以,tempnam()被禁用后,当然不能自动创建类似%%

  43^43B^43B32F4B%%index.htm.php的临时档,自然自动创建类似%%
  43^43B^43B32F4B%%index.htm.php的临时档,是一片空白.

  smarty中使用tempnam函数的程序是internals/core.write_file.php,如下代码:
<font size="2"><font face="Verdana">PHP代码:</font><hr></font><code><font color="#000000"><font color="#0000bb"><br></font><font color="#ff8000">// write to tmp file, then rename it to avoid<br> // file locking race condition<br>    </font><font color="#0000bb">$_tmp_file </font><font color="#007700">= </font><font color="#0000bb">tempnam</font><font color="#007700">(</font><font color="#0000bb">$_dirname</font><font color="#007700">, </font><font color="#dd0000">'wrt'</font><font color="#007700">);<br>    if (!(</font><font color="#0000bb">$fd </font><font color="#007700">= @</font><font color="#0000bb">fopen</font><font color="#007700">(</font><font color="#0000bb">$_tmp_file</font><font color="#007700">, </font><font color="#dd0000">'wb'</font><font color="#007700">))) {<br>        </font><font color="#0000bb">$_tmp_file </font><font color="#007700">= </font><font color="#0000bb">$_dirname </font><font color="#007700">. </font><font color="#0000bb">DIRECTORY_SEPARATOR </font><font color="#007700">. </font><font color="#0000bb">uniqid</font><font color="#007700">(</font><font color="#dd0000">'wrt'</font><font color="#007700">);<br>        if (!(</font><font color="#0000bb">$fd </font><font color="#007700">= @</font><font color="#0000bb">fopen</font><font color="#007700">(</font><font color="#0000bb">$_tmp_file</font><font color="#007700">, </font><font color="#dd0000">'wb'</font><font color="#007700">))) {<br>            </font><font color="#0000bb">$smarty</font><font color="#007700">-></font><font color="#0000bb">trigger_error</font><font color="#007700">(</font><font color="#dd0000">"problem writing temporary file '$_tmp_file'"</font><font color="#007700">);<br>            return </font><font color="#0000bb">false</font><font color="#007700">;<br>        }<br>    }<br>   </font><font color="#0000bb">fwrite</font><font color="#007700">(</font><font color="#0000bb">$fd</font><font color="#007700">, </font><font color="#0000bb">$params</font><font color="#007700">[</font><font color="#dd0000">'contents'</font><font color="#007700">]);<br>   </font><font color="#0000bb">fclose</font><font color="#007700">(</font><font color="#0000bb">$fd</font><font color="#007700">);<br></font><font color="#0000bb"></font></font></code><hr>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn