Create temporary files
Several benefits of creating temporary files:
1. Delete them after use
2. There is no need to maintain the deletion status of this file
For example: I It is necessary to transfer the file contents of A to B and the file contents of B to C.
Just like in real life, I can first use a temporary bottle to fill B's water, and then write A's data into B. Add the water from the temporary bottle to C.
Let’s learn this function:
resource tmpfile ( )
Function: Create a temporary file and return resources type. The file is deleted when it is closed.
<?php //创建了一个临时文件 $handle = tmpfile(); //向里面写入了数据 $numbytes = fwrite($handle, '写入临时文件'); //关闭临时文件,文件即被删除 fclose($handle); echo '向临时文件中写入了'.$numbytes . '个字节'; ?>
new file
<?php
//创建了一个临时文件
$handle = tmpfile();
//向里面写入了数据
$numbytes = fwrite($handle, '写入临时文件');
//关闭临时文件,文件即被删除
fclose($handle);
echo '向临时文件中写入了'.$numbytes . '个字节';
?>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















