the sun's not yellow it is chicken

Author: moonbug (Page 3 of 39)

Dead Trees

Couple of days ago I ordered a book on programming, and opted for the paperback (dead tree) version. The book was delivered to my home within two days.

People who opted for the digital download edition however, have yet to receive their download link, and are slamming the author for the faulty checkout routine… which the author himself programmed.

So now I’m not so sure whether I should trust the programming techniques as described by the author in his book.

Irony eh?

$this->lang /* FAIL */

Note to self: when dealing with a multi-language site, in a CodeIgniter extended class constructor, do not attempt this:


protected $lang;
function __construct() {
parent::__construct();
$this->lang = $this->uri->segment(1);
}

Instead you will want to do this:


	protected $language;
	function __construct() {
		parent::__construct();
		$this->language = $this->uri->segment(1);
	}

See what I did there? ‘lang’ to ‘language’.

As it happens $this->lang, when in a CI constructor, will name-conflict with any native CI system library that needs to tap into something similar to $CI =& get_instance(), with a subsequent $CI->load->lang('some_library') call.

Thank me not.

« Older posts Newer posts »

© 2024 moonbug.org

Theme by Anders NorenUp ↑