PHP Code:
function open( $mode )
// opens the data source
{
if ( ! $this->handle = fopen( $this->name, $mode ) )
{
return false;
}
else
{
// lock file if opened for write mode
if ( preg_match( '/a|w|\+/i', $mode ) )
{ flock( $this->handle, 2); }
$this->eol = feof( $this->handle );
return true;
}
}
Note: preg_match is not case insensitive as was eregi, hence the added i switch:
Code:
preg_match( '/a|w|\+/i
', $mode )
The only other difference of note here is that with preg_match delimiters must be included within the quoted string which represents the regular expression being used:
Code:
preg_match( '/
a|w|\+/
i', $mode )
I switched from double quotes to single quotes as they're generally safer if not required to resolve variables within them, which they are not here.
For more info, see:
http://us3.php.net/manual/en/function.preg-match.php
Bookmarks