Eddie On Everything

Tips & tricks on things that interest me

Entries Tagged ‘PHP’

Validating an Email Address with PHP’s filter_var isn’t perfect

So I’m working on a project where I need to validate that the user has entered a correct email address.
I don’t really care if someone sticks in a “fake” email address – to complete registration, the user needs to enter a confirmation code that I send via email, so if they put in a fake [...]

How to Make phpbb3 Forum Links Automatically rel=”nofollow”

I use phpbb3 for this site’s discussion area. It’s not a particularly popular section of the website, but it does attract one type of commenter – spammers.
Spammers like to create posts that link to their own site. They do this for two reasons – one is to drive traffic directly to their site. [...]

Getting PHP’s print_r Function To Return A String

PHP’s print_r function is invaluable. It prints a human-readable string representation of a variable.
It’s one of the most useful debugging features I’ve seen in any language.
I like it so much that I’ve actually written print_r mimic functions for other languages.
By default, print_r literally prints a variable to the screen. Sometimes it’s useful to [...]

Optimizing the Google Syntax Highlighter Wordpress Plugin Even Further

I use the Google Syntax Highlighter for Wordpress plugin to display the code I share on this page all pretty-like.
The problem is, the thing isn’t very robust – it causes every single page on your blog to load up about 10 separate javascript files, regardless of whether the plugin is actually doing anything on that [...]

PHP Programming: U.S. State list functions / State abbreviation to State name function

Here are a few PHP functions that I find useful for United States related things. Nothing brilliant or groundbreaking – just something to save you some typing.
1. A PHP function for printing a state select box
2. A PHP function that returns the full state name when passed the abbreviation
3. A PHP snippet for printing [...]

Uploading Large Files to a LAMP setup – upload_max_filesize, post_max_size, and max_allowed_packet

So you’re trying to upload a large file via PHP and you’re getting an error, eh? It’s probably because of PHP’s default configuration, which limits uploads to 2 Megs, or because of MySQL’s default 1.5 Meg limitation. Here’s how you change these defaults.
First, find your php.ini file. If you don’t know where [...]

  

Buy me a beer