PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Don't use eregi as it's been deprecated and won't be available in PHP6. I'm pretty sure you'll want to use preg_match.
Also your script doesn't look overly indepth though as a good practice when you do things like form verification you'll want to execute regular expressions as the last step of verification as it generates the most server load. So if you can catch a validation error (such as length) first then you'll be spared from creating unnecessary load (and thus poorer server performance).
JAB Creations wrote:Don't use eregi as it's been deprecated and won't be available in PHP6. I'm pretty sure you'll want to use preg_match.
Also your script doesn't look overly indepth though as a good practice when you do things like form verification you'll want to execute regular expressions as the last step of verification as it generates the most server load. So if you can catch a validation error (such as length) first then you'll be spared from creating unnecessary load (and thus poorer server performance).
how do i use it in my case. i dont know how to use it.
here's the error i am getting. Please help me its urgent. Warning: preg_match() [function.preg-match]: Unknown modifier 'g' in C:\wamp\www\godnels\imagealbum\ArchiveExtractor.class.php in line5
If you notice in all the examples, the patterns all start and end with the same character. That character is called the "delimiter". It looks like you've chosen "%" as your delimiter. Traditionally "/" is used, but "%" will work just as well.
Your first pattern is filled with multiple occurrences of "%". If you want them to be in your pattern as literal characters (ie, you want to match a percent sign & not have it treated as a delmiiter) then you need to escape it like this: "\%". Your error is being thrown because the regex engine sees the second occurrence of "%" as the closing delimiter, and tries to interpret the rest of your pattern as pattern modifiers, of which "g" is not valid.
If you're going to use regular expressions, I highly recommend reading through the Regex Crash Course Tutorial we've got.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.