Skip to main content

Posts

Showing posts from January, 2017

Magic function library for Codeigniter like CakePHP

CodeIgniter is a powerful PHP framework with a very small footprint, and very useful for website.

Today I am going to introduce you the Magic function for CI like CakePHP.

What is Magic Functions

As the name "Magic function" there are some magic with its library which you can download from here .

By using this library, you don't need to do define any function in your models all functions which you want it has already created just like magic. There is a library Magic.php which convert your function into Database Query and produce result as you want.

Clone the Magic.php in your local directory and place it into application/library in your CI project. Now set this library in application/config/autoload.php . so don't need to load in every controller.
$autoload['library'] = array('Magic');
Now your magic library is ready to use with $this->magic instance.
Structure:
$this->magic Instance of library. ->tableName set table name for fetch data from DB…

What is the difference between an interface and abstract class

This is an extremely common interview question. It's surprising since an abstract class is rarely used in solutions compared to other things.

Many junior developers make the mistake of thinking of interfaces, abstract and concrete classes as slight variations of the same thing, and choose one of them purely on technical grounds: Do I need multiple inheritance? Do I need some place to put common methods? Do I need to bother with something other than just a concrete class?

So here is a clear difference and uses of Interface and Abstract class.

The key technical differences between an abstract class and an interface are:

Abstract classes can have constants, members, method stubs (methods without a body) and defined methods, whereas interfaces can only have constants and methods stubs.
Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public (they are defined public by default).
When inheriting an abstract …