Thursday, April 26, 2012

PHP, server infomation and unique identifier



To print out server information in PHP:
<?php
 print_r($_SERVER)
?>
I tested a PHP code in my localhost:8083,  When I used $_SERVER['SERVER_NAME'], the result is
localhost.  The variable $_SERVER['HTTP_HOST'] should be used to represent localhost:8083.

Sometimes we need to use  prefixed unique identifiers as a primary key. in PHP.  PHP function uniqid() can be used, which produces a prefixed unique identifier based on the current time in microseconds.
example:
uniqid('g');   a unique identified with prefix g based on time.
uniqid('u');   a unique identified with prefix u based on time.
 

No comments:

Post a Comment