• Comparing two objects in php

    January 24, 2013

    $areSame = (serialize($ob1) === serialize($ob2)); This easy way of comparing two objects in php.It will take in account object variables. Example : class ob1{ public $number = 1; } class ob2{ public $number = 1; } $areSame = serialize(new ob1()) === serialize(new ob2()) //$areSame = true; class ob1{ public $number = 1; } class ob2{ […]

  • Change layout template based on controller in Zend Framework 2

    January 18, 2013

    In Zend Framework 2 , layout can be easily changed from module based on controller(name).   Step 1. Add in module.config.php file 'controller_layouts' => array( 'MyControllerName' => 'layout/MyControllerName', ), and 'view_manager' => array( //more options 'template_map' => array( 'layout/MyControllerName'=> PATH_TO_TEMPLATE ), ), Step 2. Add in module.php $e->getApplication()->getEventManager()->getSharedManager() ->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); […]


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /home/c2kblate/sites/ivangospodinow.com/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org