Saturday, 20 December 2014

Difference between overloading and overriding in php with Example

Difference between overloading and overriding in php with Example


Overloading: In Real world, overloading means assigning some extra stuff to someone. As as in real world Overloading in PHP means calling extra functions.
Example of Overloading:
class testclass {
    public $_data;
    public function __get($name) {
        echo "Getting '$name'\n ";
        return $this->data[$name];
    }
}

$obj = new testclass();
/** Magic method Example * */
echo $obj->a; //As __get function called - Overloading example 2
/** Magic method Example * */ 

We can do overloading with magic methods and are following:
__construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone() and __debugInfo()



Overriding: In Real world, Overriding means changing the parental behaviour in Child. As as in real world Overriding in PHP means calling of child function instead of parent function, both class's function have same name.
Example of Overriding:
class parentclass {
    function name() {
        return 'Parent';
    }
}

class childclass extends parentclass {
    function name() {
        return 'Child';
    }
}

$obj = new childclass();
echo $obj->name();//It called child function instead of parent parent function - Overriding Example


Friday, 19 December 2014

Wordpress title repeated two times in browser header [SOLVED]

Wordpress title repeated two times in browser header [SOLVED]

I add the post from wordpress admin section (http://www.example.com/wp-admin/), 
After publishing the post it start displaying in website.

In Post detail page, Every information like post title, post description and post date etc is correct except meta title.


Issue: Meta title have post name + website name + | website name.

Here meta title have website name two times at then end of page title.


Solution: 
  • Login into admin section.
  • Go to Plugins section. ( or use link: http://example.com/wp-admin/plugins.php).
  • Search for "All in One SEO Pack".
  • Click on deactivate, Now "All in One SEO Pack" is deactivated successfully.
  • Go to website and refresh the Frontend page, Now you will see two times website name in title is FIXED.