News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Alex Netkachov's Blog:
File stream wrapper is overwritable in PHP
April 01, 2009 @ 11:14:47

Alex Netkachov has found out something interesting - the default "file" stream wrapper can be overridden.

I find today that the default "file" stream wrapper in PHP is overwritable. You only need to call stream_wrapper_unregister and then stream_wrapper_register with your wrapper.

He gives an example of a situation where you might need to "catch" certain files as they're requested and replace them with another before they make it back to the source. His example code shows how to create the stream (using stream_open) and set methods to read, write, seek and work directly with the stream resource. It takes the file requested and replaces the "5" in the name - "test.php" is included instead of "test.php5".

0 comments voice your opinion now!
file stream override wrapper include


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Using a stream wrapper to access CouchDb attachments with PHP

FrSIRT Advisory: P-News Arbitrary PHP File Upload and Remote Information Disclosure Vulnerabilities

Jani Hartikainen's Blog: The problems faced by a common model interface in frameworks

Jim Plush\'s Blog: Grouping PHP classes = faster by 24%

SitePoint PHP Blog: How to Override PHP Configuration Options


Community Events





Don't see your event here?
Let us know!


voicesoftheelephpant package introduction bugfix series community library framework opinion language install symfony deployment laravel list release tips interview api podcast

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework