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

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

Jun 21, 2016 am 08:59 AM
file nbsp php tempnam tmp

  当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">-&gt;</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>
Copy after login



Statement of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles