tags:

views:

119

answers:

1

Morning all

I'm converting a site that I'm working on to be compliant with the latest version of PHP, so I'm going through and replacing all instances of ereg with their non-depreciated equivalent. However I was told about a handy built-in function with PHP called filter_var.

What my question is, is would it make sense to go with filter_var over preg_match? As in is there a performance boost or any other benefits to choosing one over the other, and if so what are they?

+2  A: 

filter_var — Filters a variable with a specified filter
preg_match — Perform a regular expression match

I guess use could use filter_var to filter variables but as a replacement for preg_match I don't think is a good idea for upgrading from ereg as filter_var doesn't use regex and you would have to rewrite a lot of the functionality/logic to do this.

Phill Pafford
I stand corrected, as I thought it did for the various items it used.
canadiancreed