Archive for April, 2008

Review: Programming PHP (2nd Edition)

Friday, April 25th, 2008

O'Reilly Programming PHPIt’s always important to have good resources when you are starting out to learn something new. Thankfully, learning PHP is much easier with books like Programming PHP (2nd edition).

Authored by Kevin Tatroe, Peter MacIntyre, and (none other than the father of the PHP language) Rasmus Lerdorf. I found this book to be an excellent, well-rounded companion for anyone doing anything with PHP.

But, is it good for the absolute beginner?

(more…)

Creating simple graphs using Google Charts API

Thursday, April 24th, 2008

Thinking back a fews years ago, I was involved in building some reporting modules with graphs and charts to show our customer utilisation of our data center. After trying a number of different open source graphing packages for PHP, I finally found JpGraph, which I daresay is probably the best graphing package available for PHP. (In my experience anyway.)

However, JpGraph requires other dependencies like GD libs - the kind of thing which we may not always have control over if we host with web hosting providers. Thankfully, there’s now a simple and easy way of building simple good looking graphs with just an <img> tag.

(more…)

Using regular expressions to extract content

Tuesday, April 22nd, 2008

PHP provides a number of really neat regular expression functions. You can find the list of the regex function at the PHP site.

But the one that I’ve had most fun with is the preg_match_all() function which I’ve been using to do content extraction from an HTML page.

(more…)

Planning your blog site

Friday, April 18th, 2008

Blogger HomeIt a real challenge to get your own website going these days, especially when you’re clueless about the website ’stuff’. Gone are the days of just creating some HTML pages, put in some graphics, and linking the pages around. These days you’ll be bombarded with so many acronyms and technologies you probably don’t even know where to start.

So what do you need to know if you’re planning to start a blog site?

(more…)

Parsing a URL querystring into variables in PHP

Thursday, April 17th, 2008

It’s common knowledge you can read variable from a URL querystring by using $_GET array in PHP, but that’s only possible if the URL is “executed” in the browser.

For those who might not know, querystrings are those variable-value pairs that appears behind ‘?’ of a URL. For example,

http://www.mysite.com/index.php?variable1=1&variable2=1

gives the querystring “variable1=1&variable2=1″.

What happens if you end up reading a URL from, say, a text file and you want to parse the querystring? In this case, the $_GET won’t work. So instead, PHP provides a function called parse_str(), which will convert the querystring into actual PHP variables within the scope of the code.

(more…)

Checking a string is alphanumeric in PHP

Friday, April 11th, 2008

There may be times when you need a way to check that a string only contains alpha-numeric characters. That means only alphabets A-Z nad numbers 0-9.

Most PHP-ers will probably use regular expressions and the function preg_match(). I will admit that regular expressions is really powerful, but it’s a real pain to learn and master. Fortunately PHP provides another function you can use.

Check out ctype_alnum() function.

(more…)

Headaches deciding Website quotes

Friday, April 4th, 2008

The other day, a friend of mine told me that she’s looking to setup a website for her small business in adventure trekking. She asked me to help her look at some website quotations she received from a few local web design companies. Promptly after I agreed, 2 quotes and her to-be-website sitemap arrived by email.

In her email, she asks which is the better quotation? When I went through what she sent me, immediately alarm bells were ringing.

(more…)

‘Cool kids’ ARE using PHP and Ruby!

Wednesday, April 2nd, 2008

Coach Wei was wondering why ‘Cool Kids’ choose Ruby or PHP over Java? In his post, the power of Java is a “perfect fit for the areas where websites may need more than markups or scripting, such as middleware logic”, whereas PHP or Ruby are not ideal for building such middleware.

For example, PHP (and Ruby) are good for simple and lightweight implementations, but sites like Facebook which started with PHP, should be ideal for Java because of it’s growing complexity.

(more…)

Google