CodeIgniter Base URL

I have a CodeIgniter dev site in Google Cloud. The instance obtains a new IP address at every start. You can set the base URL to a domain or IP address in the “/application/config/config.php” file. Since it’s only a dev box, I don’t have a domain assigned. It’s accessible via IP address only which changes every time the instance is started. So here’s the workaround. I added some extra code in the config file to obtain the external IP address.

$realIP = file_get_contents("");
$config['base_url'] = 'http://'.$realIP;

The code is using a service from which returns your external IP address. Works like a charm!

Dynamic Footer

Many web designers use Copyright followed by the current year on the bottom of their websites. It’s usually placed in the footer section of the page. If your site has been around for a while, spanning over several years, you’ll have to update your footer every time a new year comes along. If your site runs on PHP, you can make your footer a little bit more dynamic by using the PHP date function.

For example, you have a footer similar to this.

Copyright © 2010 - 2014. All rights reserved.

The result is:

Copyright © 2010 – 2014. All rights reserved.

You can make the current year dynamic by using the PHP date function as displayed below.

Copyright &#169; 2010 - <?php echo date('Y'); ?>. All rights reserved.

Most web hosting services have PHP turned on by default. Even if your website runs only in HTML, you can probably use the PHP date function. If you decide to do it, just make sure to change the file extension from .html to .php. And you’re good to go.