Zend Framework Interview Questions and Answers
Ques 11. Zend_Cache provides a generic way to cache any data.
Caching in Zend Framework is operated by frontends while cache records are stored through backend adapters (File, Sqlite,Memcache...) through a flexible system of IDs and tags. Using those, it is easy to delete specific types of records afterwards (for example: "delete all cache records marked with a given tag").
The core of the module (Zend_Cache_Core) is generic, flexible and configurable. Yet, for your specific needs there are cache frontends that extend Zend_Cache_Core for convenience: Output, File, Function and Class.
Ques 12. Difference between Zend_Registry and Zend_Session?
The basic difference between these objects is the ‘scope’ in which they are valid:
a) Zend_Registry : request scope
b) Zend_Session : session scope
a) Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.
b) Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.
Ques 13. When do we need to disable layout?
At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
Ques 14. Where is the model in ZF’s MVC implementation?
The model component can vary dramatically in responsibilities and data store from one MVC application to the next.
Ques 15. How to call two different views from same action?
Example1:
Public function indexAction() {
If(condition)
$this->render(‘yourview.phtml’);
Else
Index.phtml;
Example2:
Public function indexAction() {
}
Now in your index.phtml you can have this statement to call other view
$this->action(‘action name’,’controller name’,’module name’,array(‘parameter name’=>’parameter value’));
Most helpful rated by users:
- What is a framework?
- Why should we use framework?
- Configuration in Zend Framework, application.ini file?
- Checking whether form posted or not in Zend framework?
- Does Zend Framework support PHP 4?