PHP5 and PHP7 new functions()

Discuss general web development questions. Help others and get help from others.

Moderator: kfury77

PHP5 and PHP7 new functions()

Postby webstar59 » Fri Jan 17, 2020 9:13 pm

Just doing some upgrades on my old PHP5 email scripts I use. The function eregi() is no longer supported in PHP7. This is how I validate email fields. String regular expression. Funny how PHP5 lets you not have /slashes/. If you want case insensitive add an/ i at the end.

Code: Select all
// Warning

// This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.

// Alternatives to this function include:

    preg_match() (with the i (PCRE_CASELESS) modifier)

eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)

// this is how I have it working now in PHP 7...

preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", $email)
Posts: 3
Joined: Tue Jan 14, 2020 11:46 pm

Re: PHP5 and PHP7 new functions()

Postby hstep528 » Wed Mar 25, 2020 4:30 pm

Michael Loeb Photography a Member of Wedding and Portrait Photographer's International for many year, Professional Photographers of various California venues, Organized Photo Workshops in Wedding, Other Photography and Photoshop for the Professional Photographers Association, and the long standing Wedding Photographer's Guild. Michael's work is available in both color and black and white. Michael's studios are based in the San Francisco Bay Area, California.
Posts: 1
Joined: Wed Mar 25, 2020 4:25 pm

Return to Web Developer Talk

Who is online

Users browsing this forum: No registered users and 1 guest