Gordonmac Dot Com

Mostly a web development blog

Category: PHP

PHP_Logo

Validating e-mail addresses in PHP

Posted: November 17th, 2011 | Tags: | Posted in: PHP, Tutorials

This is easily the best function I’ve used for validating e-mail addresses in my PHP scripts and applications. function is_valid_email($email) { $qtext = ‘[^\x0d\x22\x5c\x80-\xff]’; $dtext = ‘[^\x0d\x5b-\x5d\x80-\xff]’; $atom = ‘[^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+’; $quoted_pair = ‘\x5c[\x00-\x7f]’; $domain_literal = “\x5b($dtext|$quoted_pair)*\x5d”; $quoted_string = “\x22($qtext|$quoted_pair)*\x22”; $domain_ref = $atom; $sub_domain = “($domain_ref|$domain_literal)”; $word = “($atom|$quoted_string)”; …
Read more…

WordPress_blue_logo.svg

Displaying recent posts in the WordPress sidebar

Posted: November 14th, 2011 | Tags: | Posted in: PHP, Tutorials, Wordpress

To add recent posts navigation to your WordPress blog, simple add the following code to sidebar.php. <h2>Recent Posts</h2> <nav id=”navigation-recent”> <ul> <?php $recent_posts = wp_get_recent_posts(5); foreach( $recent_posts as $recent ){ $date = date(“M d, Y”,strtotime($recent[“post_date”])); echo ‘<li><a href=”‘ . get_permalink($recent[“ID”]) . ‘” title=”Look ‘.$recent[“post_title”].'” >’ . $recent[“post_title”].'</a> ‘.$date.'</li>’; …
Read more…

WordPress_blue_logo.svg

Customising the WordPress admin area

Posted: August 23rd, 2011 | Tags: | Posted in: PHP, Tutorials, Wordpress

If you would like to customise your WordPress admin pages these functions are an excellent start. In this little tutorial we’ll look at customising the WordPress logo in the WordPress admin area, editing the WordPress admin footer to include your own company name and also customising the “Howdy” …
Read more…