Phar::interceptFileFuncs

(PHP >= 5.3.0, PECL phar >= 2.0.0)
instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions
final public static void Phar::interceptFileFuncs ( void )

instructs phar to intercept fopen(), readfile(), file_get_contents(), opendir(), and all of the stat-related functions. If any of these functions is called from within a phar archive with a relative path, the call is modified to access a file within the phar archive. Absolute paths are assumed to be attempts to load external files from the filesystem.

This function makes it possible to run PHP applications designed to run off of a hard disk as a phar application.

Returns:
Examples:
A Phar::interceptFileFuncs() example
<?php
Phar::interceptFileFuncs();
include 'phar://' . __FILE__ . '/file.php';
?>

A Phar::interceptFileFuncs() example

Assuming that this phar is at /path/to/myphar.phar and it contains file.php and file2.txt, if file.php contains this code:

<?php
echo file_get_contents('file2.txt');
?>

doc_php
2016-02-24 15:55:15
Comments
Leave a Comment

Please login to continue.