Just a little post, because most of the top Google results point to old pages that aren't correct.
Basically, I wanted to validate some input to see if it was a valid email address. Rather than rely on a regular expression, I knew there was a better way of doing it. In PHP at least.
So, the function you're looking for is filter_var(). If you're doing it with $_POST or $_GET you can instead use filter_input().
In my case, it's verifying that an API is providing me with a valid email, as somebody at the other end likes to chuck in "unsubscribed" to the email field. So the code looks similar to this.
if (false === filter_var($valueToCheck, FILTER_VALIDATE_EMAIL) ) {
// This is *not* an email address
} else {
// This *is* an email address
}
A short blog designed to show all the interesting things I pick up while working with PHP based websites.
Tuesday, 6 March 2012
Tuesday, 29 November 2011
Amazon cloud servers
They may sound like the silver bullet to kill all silver bullets.
But judging from the swearing coming from the Systems Administrator from the other side of the desk lately, I think I may steer clear of them for a little while yet.
But judging from the swearing coming from the Systems Administrator from the other side of the desk lately, I think I may steer clear of them for a little while yet.
Monday, 28 November 2011
Pimcore and it's Jekyll and Hyde-ness
I am playing with Pimcore to try and learn what it can do, as well as for a friends website. I was having all sorts of issues with getting it to work, however, mainly because some PHP extensions weren't installed locally. Or it wasn't the up to date version. I'm not really sure which.
So after installing php5-imagick (sudo apt-get install php5-imagick) I seem to have fixed the issues with the image uploader and viewing images while editing content.
So that got me to playing with thumbnails to constrain an image to the size I wanted it to be. And that's when I discovered you can automatically make images have rounded corners. How cool is that??
So many options hidden in this CMS that I don't think I'll ever fully understand it.
So after installing php5-imagick (sudo apt-get install php5-imagick) I seem to have fixed the issues with the image uploader and viewing images while editing content.
So that got me to playing with thumbnails to constrain an image to the size I wanted it to be. And that's when I discovered you can automatically make images have rounded corners. How cool is that??
So many options hidden in this CMS that I don't think I'll ever fully understand it.
Subscribe to:
Posts (Atom)