Created
September 12, 2012 09:45
-
-
Save zmiftah/3705591 to your computer and use it in GitHub Desktop.
PHP: ereg function Deprecated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Source: http://www.devthought.com/2009/06/09/fix-ereg-is-deprecated-errors-in-php-53/ | |
// | |
// To migrate ereg(): | |
ereg('\.([^\.]*$)', $this->file_src_name, $extension); | |
// becomes | |
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension); | |
// Notice that I wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. | |
// If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead. | |
//Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter: | |
eregi('\.([^\.]*$)', $this->file_src_name, $extension); | |
// becomes | |
preg_match('/\.([^\.]*$)/i', $this->file_src_name, $extension); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment