The 'Final' Keyword

No! I am not starting off on that song by that 80's dude that your parents sing. I am in fact referring to the not so handy keyword final keyword that is readily available to you from PHP5 onwards. Why use my words when other words can help:

[php] <?php final class QuinnClass { public function test() { echo "hello"; } } class Child extends QuinnClass { } // Fatal error: Class Child may not inherit from final class (QuinnClass) in /Applications/MAMP/htdocs/test/index.php on line ## ?> [/php]

The moment you plonk the final keyword on, you aint going any further in terms of extension or what not. I personally don't find any use for it in classes as if you have a large distribution of code out there, this keyword isn't going to be very helpful. It locks down your class. My naivety might be clouding my judgement so do correct me and give me some helpful knowledge in terms of real world application. Its not just classes it can be applied to though, class methods too:

[php] <?php final class QuinnClass { public function test() { echo "hello"; } } class Child extends QuinnClass { } QuinnClass::test(); // Fatal error: Cannot override final method QuinnClass::test() in /Applications/MAMP/htdocs/test/index.php on line ## ?> [/php]

Other than believing your code is so perfect you can't bear the thought of any other open source joe to touch your code then using the final keyword doesn't seem much kop. I could be wrong...

Monthly Archives: May 2014

PHP – the final keyword

The ‘Final’ Keyword No! I am not starting off on that song by that 80’s dude that your parents sing. I am in fact referring to the not so handy keyword final keyword that is readily available to you from PHP5 onwards. Why use my words when other words can help: The moment you plonk

Read more

Em media queries

How do you find using em’s in media queries? Perhaps you use a base font size of 62.5%? and wish to throw this into your media queries: Try this And your query is kicking in nowhere near 960px?? Well that’ll be because media query is irrespective of font-size set by body. It’s all relative. Straight

Read more