Re: Found some incompatibilities
messju mohr <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Mar 02, 2004 at 12:40:45PM -0800, boots wrote: > --- messju mohr <[email protected]> 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 -- Smarty Development Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php