⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 08c09-1.php

📁 介绍PHP5的给类型函数应用
💻 PHP
字号:
<?php// Open the file to append data to itif (!($fp = fopen('data.log', 'a'))) {	die ('ERROR: Could not open file!');}// At this point we need to remove the ability for a user to abortignore_user_abort(true);// Now attempt to get an exclusive lockif (!(flock($fp, LOCK_EX))) {	die('ERROR: Could not get exclusive lock!');}// We now have the lock, To make sure that another file didn't// write data into this file while we waited for the lock, seek// to the end of the file:fseek($fp, 0, SEEK_END);// Now we can write our data:fwrite($fp, 'A Random Number: ' . rand() . "\n");// Close the file - Which also releases the lockfclose($fp);// And now allow a user abort again:ignore_user_abort(false);// Now echo out our file contents so that we can see what happened:echo '<pre>';readfile('data.log');echo '</pre>';?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -