Re: Problems with writing a stream wrapper to regular fopen/close functions...
| From: | Curt Zirzow | Date: | Tue, 31 Aug 2004 04:50:59 +0000 |
| Subject: | Re: Problems with writing a stream wrapper to regular fopen/close functions... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195244@lists.php.net to get a copy of this message | ||
* Thus wrote John Holmes:
>
> This is the file that defines the custom stream and some of the
> implementation. Not all methods are implemented, but I don't think that
> matters to this issue.
> --------------------
> Custom Stream Class:
> <?php
>
> stream_wrapper_register('cache','CacheStream');
>
> class CacheStream
> {
> public $fp = FALSE;
> public $foo = FALSE;
>
> function stream_open($path, $mode, $options='', &$opened_path='')
> {
> $path = substr($path,8);
> $this->fp = fopen($path,$mode);
> $this->foo = ' Test String ';
> var_dump($this->fp);
> var_dump($this->foo);
> return $this->fp;
> }
change return to:
return ($this->fp? true: false);
technically, internally the function is treated as
function &stream_open(...)
and will convert the value to a boolean value as you were
experiencing.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!