posix-ere

Why is `ereg` deprecated in PHP?

邮差的信 提交于 2019-11-28 05:21:30
问题 Why is ereg deprecated in PHP? I had a lot of functions which used this, now they always give warning. What is the alternative of this too? 回答1: http://pl.php.net/manual/en/function.ereg.php Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE. 回答2: Ereg is deprecated because it was replaced by the the PCRE extension. The reason(s) it was

ereg/eregi replacement for PHP 5.3 [duplicate]

走远了吗. 提交于 2019-11-27 20:39:54
This question already has an answer here: How can I convert ereg expressions to preg in PHP? 4 answers I'm sorry to ask a question but I am useless when it comes to understanding regex code. In a php module that I didn't write is the following function function isURL($url = NULL) { if($url==NULL) return false; $protocol = '(http://|https://)'; $allowed = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; $regex = "^". $protocol . // must include the protocol '(' . $allowed . '{1,63}\.)+'. // 1 or several sub domains with a max of 63 chars '[a-z]' . '{2,6}'; // followed by a TLD if(eregi($regex, $url)==true)

PHP ereg vs. preg

吃可爱长大的小学妹 提交于 2019-11-27 17:06:30
问题 I have noticed in the PHP regex library there is a choice between ereg and preg. What is the difference? Is one faster than the other and if so, why isn't the slower one deprecated? Are there any situations where it is better to use one over the other? 回答1: Visiting php.net/ereg displays the following: Warning This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. Down the page just a bit further and we read this: Note:

How to replace ereg?

本小妞迷上赌 提交于 2019-11-27 06:51:38
问题 I'm getting the following message for some php I have to use but did not write: Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/html2fpdf.php on line 466 This is line 466: if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) I tried simply replacing with preg_match, but it couldn't recognize the = modifier in the regular expression.. I'm not too good with regular expression yet and solving this requires that I learn the regexp ereg needs AND the regexp

How to change PHP's eregi to preg_match [duplicate]

眉间皱痕 提交于 2019-11-27 01:51:47
Possible Duplicate: How can I convert ereg expressions to preg in PHP? I need help, below is a small VERY basic regex to somewhat validate an email, I do realize it does not work the greatest but for my needs it is ok for now. It currently uses PHP's eregi function which php.net says is now a depreciated function and I should use preg_match instead, simply replacing erei with preg_match does not work, can someone show me how to make it work? function validate_email($email) { if (!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $email)) { echo 'bad email'; } else { echo 'good email';

Deprecated: Function split() is deprecated. How to rewrite this statement?

感情迁移 提交于 2019-11-26 09:12:25
问题 I have the following statement which worked fine before PHP 5.3 using the split function: list($year, $month, $day, $hour, $min, $sec) = split( \'[: -]\', $post_timestamp ); After upgrading to PHP 5.3, I get the Deprecated warning: Deprecated: Function split() is deprecated. I am trying to parse a string with format like: 2010-08-10 23:07:58 into its component parts. 回答1: I think you want preg_split. list($year, $month, $day, $hour, $min, $sec) = preg_split('/[: -]/', $post_timestamp); 回答2: