Re: [SMARTY-DEV] Found some incompatibilities
| From: | messju mohr | Date: | Tue, 02 Mar 2004 22:02:00 +0000 |
| Subject: | Re: [SMARTY-DEV] Found some incompatibilities | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2173@lists.php.net to get a copy of this message | ||
On Tue, Mar 02, 2004 at 12:40:45PM -0800, boots wrote:
> --- messju mohr <messju@lammfellpuschen.de> wrote:
> > I think we'll fix it if 4.3.5 really ships with that warning on
> > fread($fp,0).
>
> I was just wondering if there is an opportnity to use switch/ifdef type
> of implementations for certain PHP features that have matured since
> they were first implemented in Smarty. In this case, if
> file_get_contents() is not a defined function, then resort to using
> old-fashioned fread() functionality. Here, old fread() code continues
> to work on old platforms and effort used to update Smarty can be
> focused on implementing the latest (and presumably greatest) extensions
> to keep the code-base fresh.
I also thought about file_get_contents and wondered what is better:
$filesize = filesize($filename);
$contents = ($filesize > 0) ? fread($fd, $filesize) : '';
or something along:
if (function_exists('file_get_contents'))
$contents = file_get_contents($filename);
else
$contents = fread($fd, filesize($filename));
I have no strong preference for the one or the other. Overall I think
it is correct for php to issue a warning if it is requested to read
zero bytes.
On another note: While I looked at _read_file() I noticed that it
provides functionality to read only sub-parts of a file (only $n..$m
lines). But this functionality is never used from withing Smarty. We
could save about 20 lines in core Smarty.class.php if we abandon this
unused feature.
> Always with the 2c,
> xo boots