Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

wincache_refresh_if_changed(3) [php man page]

WINCACHE_REFRESH_IF_CHANGED(3)						 1					    WINCACHE_REFRESH_IF_CHANGED(3)

wincache_refresh_if_changed - Refreshes the cache entries for the cached files

SYNOPSIS
bool wincache_refresh_if_changed ([array $files = NULL]) DESCRIPTION
Refreshes the cache entries for the files, whose names were passed in the input argument. If no argument is specified then refreshes all the entries in the cache. PARAMETERS
o $files - An array of file names for files that need to be refreshed. An absolute or relative file paths can be used. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
WinCache performs regular checks on the cached files to ensure that if any file has changed then the corresponding entry in the cache is updated. By default this check is performed every 30 seconds. If, for example, a PHP script updates another PHP script where the applica- tion's configuration settings are stored, then it may happen that after the configuration settings have been saved to a file, the applica- tion is still using old settings for some time until the cache is refreshed. In those cases it may be preferrable to refresh the cache right after the file has been changed. The following example shows how this can be done. Example #1 A wincache_refresh_if_changed(3) example <?php $filename = 'C:inetpubwwwrootconfig.php'; $handle = fopen($filename, 'w+'); if ($handle === FALSE) die('Failed to open file '.$filename.' for writing'); fwrite($handle, '<?php $setting=something; ?>'); fclose($handle); wincache_refresh_if_changed(array($filename)); ?> SEE ALSO
wincache_fcache_fileinfo(3), wincache_fcache_meminfo(3), wincache_ocache_fileinfo(3), wincache_ocache_meminfo(3), wincache_rplist_file- info(3), wincache_rplist_meminfo(3), wincache_ucache_meminfo(3), wincache_ucache_info(3). PHP Documentation Group WINCACHE_REFRESH_IF_CHANGED(3)

Check Out this Related Man Page

FWRITE(3)								 1								 FWRITE(3)

fwrite - Binary-safe file write

SYNOPSIS
int fwrite (resource $handle, string $string, [int $length]) DESCRIPTION
fwrite(3) writes the contents of $string to the file stream pointed to by $handle. PARAMETERS
o $handle -A file system pointer resource that is typically created using fopen(3). o $string - The string that is to be written. o $length - If the $length argument is given, writing will stop after $length bytes have been written or the end of $string is reached, whichever comes first. Note that if the $length argument is given, then the magic_quotes_runtime configuration option will be ignored and no slashes will be stripped from $string. RETURN VALUES
fwrite(3) returns the number of bytes written, or FALSE on error. NOTES
Note Writing to a network stream may end before the whole string is written. Return value of fwrite(3) may be checked: <?php function fwrite_stream($fp, $string) { for ($written = 0; $written < strlen($string); $written += $fwrite) { $fwrite = fwrite($fp, substr($string, $written)); if ($fwrite === false) { return $written; } } return $written; } ?> Note On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen(3) mode parameter. Note If $handle was fopen(3)ed in append mode, fwrite(3)s are atomic (unless the size of $string exceeds the filesystem's block size, on some platforms, and as long as the file is on a local filesystem). That is, there is no need to flock(3) a resource before calling fwrite(3); all of the data will be written without interruption. Note If writing twice to the file pointer, then the data will be appended to the end of the file content: <?php $fp = fopen('data.txt', 'w'); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); // the content of 'data.txt' is now 123 and not 23! ?> EXAMPLES
Example #1 A simple fwrite(3) example <?php $filename = 'test.txt'; $somecontent = "Add this to the file "; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> SEE ALSO
fread(3), fopen(3), fsockopen(3), popen(3), file_get_contents(3). PHP Documentation Group FWRITE(3)
Man Page