Archive for June, 2008

Generate PHP Random String

Monday, June 30th, 2008

It’s easy to use to use the rand(min, max) function to generate a random number between min and max (inclusive).

Here is a clever way of using rand() and chr() function to generate a random string:

chr(rand(65,90)) will generate a random character between A – Z (capital)

chr(rand(97,122)) will generate a random character between a – z (lower case)

Therefore, if you want to generate a 5 character long string of random string (assuming all lower case), you would write:


Or you can write a simple for() loop and concatenate them together.

Hope that helps.

HTML link with no underline

Thursday, June 19th, 2008

Creating a HTML anchor text link with no underline is really simple.

By default, a hyperlink tag has the following structure:

<a href=””>PHP Forums</a>

When viewed in browser, it shows as:

PHP Forums

If you want to get rid of the underline, you can specify it in the CSS style property:

<a href=”” style=”text-decoration:none;”>PHP Forums</a>

When viewed in browser, it will show as:

PHP Forums

Subsequently, if there is a CSS stylesheet that forces all anchor tags to be displayed without an underline, you can use style=”text-decoration:underline;” to turn it back on.

Free PHP Tutorial

Wednesday, June 18th, 2008

Periodically we will publish free, helpful PHP tutorials for your application or program.

If you have a PHP tutorial and would like to share it with us, feel free to register at our site and make your submission.

In our PHP tutorial archive, we have tutorials that were published years ago (date back to 2003). While they are a good starting point, you may also want to try our PHP forum where you can get specific questions answered. is also a very good starting point. Our PHP functions forums is a place to further compliment’s function reference where we discuss practical function usage and examples.

Stay tuned…

Passing values in the URL in PHP

Tuesday, June 17th, 2008

It is very easy to pass values in the URL as a query string, and get those values to a PHP processor file.

For example, if we want to pass a tracking session ID in the URL, such as:

In our tracking.php, we can print out the value that is passed in via the URL by referencing to $_GET[session] or $_REQUEST[session] variable:

echo $_REQUEST[session]; Re-launched!

Monday, June 16th, 2008

For years was pretty dead.

Finally I have some time to give it a face lift (using WordPress as homepage, and Simplemachine forum as the forum app) and will be able to get involved in the forum and answer some of your tough questions.

Whether you are a beginning PHP programmers, webmasters, or an expert, you are welcomed to participate and help each other out.

You are invited to submit your PHP tutorials. Simple register to this blog and start posting away.

PHP query string without question mark

Monday, June 16th, 2008

If you want to pass variables in the URL without having to use ?var=value format, then you will need .htaccess file and a URL RewriteRule.

For example, let’s say we want to pass a variable via the query string, then we would use a .htaccess file and place it in the public_html folder.

The .htaccess file would like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.+)=(.+)$ /index.php?$1=$2

Notice the use of regular expression:

^ denotes the beginning of the line
$ denotes the end of the line

We use ( ) to enclose a regular expression match, so the value of the first match would be in $1, and second would be in $2.

The RewriteRule says that whatever query matches that regular expression, we would redirect the request to /index.php?$1=$2 where $1 and $2 are the values of the match.