Feed on
Posts
Comments

Tag Archive 'PHP'

So, I was working on a project that generates a form based on a selection of items from a database, and the form could get pretty long. For performance testing I timed the execution of the script and found some very odd results. If the number of items on the list was 16 [...]

Read Full Post »

This evening I got a comment on my post about how to detect when cell phones access your web site. It was a question about the way I went about the PHP code for matching a bunch of small text snippets against the User Agent string.

Basically, I put all the text snippets in a [...]

Read Full Post »

Replacing a short bit of text in PHP is easy. You just use str_replace, as in $bobo = str_replace("foo","bar",$bobo). That will replace all instances of "foo" with "bar" in the string $bobo.

But, on a recent contract, I had a client's site where it only worked properly in Microsoft Internet Explorer and part of [...]

Read Full Post »

Validation is the art of checking and modifying input from users so that it's all of what your web site needs and none of what it doesn't want. Validation can be as complex as anti-hacking and anti-spam measures or as simple as making sure someone's not putting their phone number in the box meant [...]

Read Full Post »

While a lot of people have written in with kudos on my PHP code for detecting mobile browsers, others have written in with questions on how to use it.

The code in question is a PHP function that returns a true or false value depending on whether the browser viewing the page has been identified as [...]

Read Full Post »

UPDATE: The code has just been tested against the WURFL database of over 6,750 different mobile browser User Agent IDs, and proved 94.34% effective at catching the User Agent IDs in their database, yet providing NO false positives on the 63 most popular browser/OS combos on the desktop. And remember, that's just one of [...]

Read Full Post »

When I've read PHP tutorials and you've got a list of values you want to check a variable against, the values are usually in an array, and a loop is used to check the variable against each value.

For example, we'll look at this block of code, assuming that $userin is user input...

$people = array("fred","wilma","barney","betty","pebbles","bam bam");
$match=false;
for($i=0;$i<count($people);$i++){
     [...]

Read Full Post »

What is "link cloaking", you ask? It's when you use an alternative URL to represent the actual URL you're linking to. For example, if you were linking to http://www.fakeurl.jib/blog/post.php?postname=why_the_heck_is_this_url_so_long, you might instead cloak it and link to http://www.mysite.jib/linkout.php?link=89.

The arguments for link cloaking include:

Easier link/click tracking
Making links short enough to fit in [...]

Read Full Post »

You've seen them as a feature of Web 2.0 web sites, big bunches of keywords called tags or a tag cloud. You've got a large database of items and you'd like to add this feature to your site. It's easier than you might think.

Step 1: Getting The Tags From Your Users
The first part [...]

Read Full Post »

Author's Note: Now the stuff below is not the code you'd use if you were building the next Digg. It's just a simple demonstration of the concepts. But if you're looking to start building your own rating script, it's an excellent start to get you familiar with how the most elemental functions [...]

Read Full Post »

While working on some projects, I wanted to develop a comment engine, so people could comment on posts. I know, I could just use a blog, but a blog wouldn't have fit these applications.
Additionally, I wanted comment threading and to be able to sort the hierarchy simply, using a minimum of RAM and CPU [...]

Read Full Post »

You've all seen the URL that looks like this... http://www.somesite.com/article.php?articleid=598&refloc=hp. You've also seen URLs that look like this... http://www.somesite.com/article/598/hp/. The interesting thing is that it only takes about 4 more lines of computer code for the shorter URL to do the exact same thing as the longer one.

Although it's not so much of [...]

Read Full Post »