Search
Syndication
Sponsors

Archive for the ‘Source Code’ Category

IPhone detection

Wednesday, February 17th, 2010

if (stristr($_SERVER['HTTP_USER_AGENT'], ‘iPhone’))
{
// redirect to an iphone version
}

Match an email address

Sunday, February 14th, 2010

$match = ‘/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/’;

preg_match($match, $email);

Shortcode example

Sunday, February 14th, 2010

{
return 'hello world';
// or echo
}
?>

Then add [helloworld] to the post.

Use a specific font

Thursday, October 1st, 2009

This example shows how to use a specific font.


<?php
header("Content-type: image/gif");
$image = imagecreate( 500, 250 );
$blue = imagecolorallocate($image, 0,0,255 );
$font = "ARIALBD.TTF";
imageTTFtext( $image, 50, 0, 20, 100, $blue, $font, www.getphp.net );
imagegif($image);
?>

What version of PHP

Thursday, September 10th, 2009

I was asked how to get the version of PHP , this was due to the minimum requirements of a script stating PHP 5 and  a user wanted to know how he could check what his host supplied.

This is the simplest version, save as version.php, upload and  then open it in your web browser.

<?php
echo phpversion();
?>

On my XAMPP installation it displayed 5.2.6