Zend Interview Questions & Answers

  1. Question 1. What Is Autoloader?

    Answer :

    Autoloader is function that load all the object on start up.

  2. Question 2. What Is Use Of Zend Front Controller?

    Answer :

    Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.

  3. CSS3 Interview Questions

  4. Question 3. What Is The Use Of Bootstrap?

    Answer :

    Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.

  5. Question 4. Is Zf A Component Library Or A Framework?

    Answer :

    ZF is both. Zend Framework provides all the components required for most web applications in a single distribution. But Zend Framework components are also loosely coupled, making it easy to use just a few components in a web application- even alongside other frameworks! Using this use-at-will architecture, we are implementing features commonly found in more monolithic frameworks. In fact, we are currently working on a tooling component for the 1.8 release that will make it simpler to build applications using ZF components, yet will not sacrifice the use-at-will nature of existing ZF components. It’s a testament to the use-at-will architecture of Zend Framework that the tooling component itself can be used standalone.

  6. CSS3 Tutorial

  7. Question 5. Zend Auth?

    Answer :

    It is used to authenticate user, for example like admin, general etc.

  8. HTML Interview Questions

  9. Question 6. Zend Acl?

    Answer :

    Based on the zend authentication it allows the user to access certain actions.

  10. Question 7. How Do You Set Module Name, Controller Name, And Action Name In Zend Framework?

    Answer :

    a) $request->setModuleName(‘front’);
    b) $request->setControllerName(‘address’);
    c) $request->setActionName(‘addresslist’);

  11. HTML Tutorial
    PHP Interview Questions

  12. Question 8. Configuration In Zend Framework, Application.ini File?

    Answer :

    Configuration can be done in application.ini file in Zend framework. This file in the path application/ configs/application.ini.

  13. Question 9. Checking Whether Form Posted Or Not In Zend Framework?

    Answer :

    $request = $this->getRequest();
    $_GET = $request->getParams();
    $_POST = $request->getPost();

  14. MySQL Interview Questions

  15. Question 10. Does Zend Framework Support Php 4?

    Answer :

    No. Zend Framework was built to use all of the sophisticated object oriented features of PHP 5 and take advantage of significant performance and security enhancements.

  16. PHP Tutorial

  17. Question 11. Fetch Last Inserted Id, Fetch All Record And Fetch A Single Record.

    Answer :

    $this->_db->lastInsertId();
    $this->_db->fetchAll($sql);
    $this->_db->fetchRow($sql);

  18. Linux Interview Questions

  19. Question 12. Difference Between Zend_registry And Zend_session?

    Answer :

    The basic difference between these objects is the ‘scope’ in which they are valid:
    a) Zend_Registry : request scope
    b) Zend_Session : session scope

    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 prepared for global use using the Zend_Registry object.

    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.

  20. CSS3 Interview Questions

  21. Question 13. When Do We Need To Disable Layout?

    Answer :

    At the time of calling AJAX to fetch we need to disable layout.
    $this->_helper->layout()->disableLayout();
    $this->_helper->viewRenderer->setNoRender(true);

  22. MySQL Tutorial

  23. Question 14. Filters In Zend Framework With Examples?

    Answer :

    The Zend_Filter component provides a set of commonly needed data filters. It also provides a simple filter chaining mechanism by which multiple filters may be applied to a single datum in a user-defined order.

    Example:

    // Add an email element
    $this->addElement(‘text’, ‘email’, array(
    ‘label’ => ‘Your email address:’,
    ‘required’ => true,
    ‘filters’ => array(‘StringTrim’),
    ‘validators’ => array(
    ‘EmailAddress’,
    )
    ));

    Other Filters:
    Alnum – Zend_Filter_Alnum is a filter which returns only alphabetic characters and digits. All other characters are supressed.
    Alpha – Zend_Filter_Alpha is a filter which returns the string $value, removing all but alphabetic characters. This filter includes an option to also allow white space characters.

  24. Question 15. Name Some Important Component In Zend Framework?

    Answer :

    Uses of Zend_Controller
    Gives the request & response methods by using its sub-classes.
    $request = new Zend_Controller_Request_Http()
    $response = new Zend_Controller_Response_Http()

    Uses of Zend_Date
    Date related processing can be done using this component.

    Uses of Zend_File_Transfer
    it provides extensive support for file uploads and downloads.

    Uses of Zend_Db
    It is used to doing database related purpose in our appication.

    Uses of Zend_Paginator
    Doing the pagination in our application.

    Uses of Zend_Auth
    It is used to authenticate a user.

    $auth = Zend_Auth::getInstance();
    $results = $auth->authenticate($adapter);
    if ($results->isValid()){
    /* user successfully authenticate into login process */
    }

    Zend_Session_Namespace
    This is a simple proxy class to use API into the Zend_Session managed $_SESSION Superglobal.

  25. Drupal Interview Questions

  26. Question 16. Where Is The Model In Zf’s Mvc Implementation?

    Answer :

    The model component can vary dramatically in responsibilities and data store from one MVC application to the next.

  27. Linux Tutorial

  28. Question 17. How To Call Two Different Views From Same Action?

    Answer :

    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’));

  29. Magento Interview Questions

  30. Question 18. Can We Call A Model In View?

    Answer :

    Yes, you can call a model in view. Simple create the object and call the method.

  31. HTML Interview Questions

  32. Question 19. Which Version Of Php Does Zend Framework Require?

    Answer :

    Zend Framework requires PHP 5.2.4 and up. Some Zend Framework components may work with earlier versions of PHP, but these components are tested and supported only on 5.2.4 and up.

  33. Drupal Tutorial

  34. Question 20. Where’s The Model?

    Answer :

    Unlike the view and the controller components, the model component can vary dramatically in responsibilities and data storage from one MVC application to the next. It should represent what your application does in the abstract. The Zend Framework community has not defined a model interface, class, or other formalism because we haven’t identified enough added value to justify limitations on what constitutes a model.

  35. MVC Framework Interview Questions

  36. Question 21. How Do U Set Module Name, Controller Name, And Action Name In Zend Framework?

    Answer :

    1. $request->setModuleName(‘front’);
    2. $request->setControllerName(‘address’);
    3. $request->setActionName(‘addresslist’);
  37. Question 22. Where Is The Model In Zf’s Mvc Implementation?

    Answer :

    The model component can vary dramatically in responsibilities and data store from one MVC application to the next.

  38. Magento Tutorial

  39. Question 23. How Do U Define The Library Path In Zend ?

    Answer :

    create directory ‘library’, and put ‘Zend’ directory in it. Your directory structure will look like this:

    wwwroot
    application
    lib
    Zend
    public
    index.php

    now you should add library to your include path. Edit index.php file:

    $includePath = array();
    $includePath[] = ‘.’;
    $includePath[] = ‘./../application’;
    $includePath[] = ‘./../library’;
    $includePath[] = get_include_path();
    $includePath = implode(PATH_SEPARATOR,$includePath);
    set_include_path($includePath);
  40. CSS Interview Questions

  41. Question 24. Can We Rename The Application Folder ?

    Answer :

    yes you can rename the application folder.

  42. PHP Interview Questions

  43. Question 25. Can We Move The Index.php File Outside The Public Folder?

    Answer :

    yes you can move index.php file outside the public folder.

  44. MVC Framework Tutorial

  45. Question 26. How To Include Js From Controller And View In Zend

    Answer :

    From within a view file: $this->headScript()->appendFile(‘filename.js’);
    From within a controller: $this->view->headScript()->appendFile(‘filename.js’);

    And then somewhere in your layout you need to echo out your headScript object:

    headScript();?>

  46. WordPress Interview Questions

  47. Question 27. How To Include Css From Controller And View In Zend

    Answer :

    From within a view file: $this->headLink()->appendStylesheet(‘filename.css’);
    From within a controller: $this->view->headLink()->appendStylesheet(‘filename.css’);

    And then somewhere in your layout you need to echo out your headLink object:

    headLink();?>

  48. MySQL Interview Questions

  49. Question 28. How Do You Protect Your Site From Sql Injection In Zend When Using Select Query?

    Answer :

    You have to quote the strings,

    $this->getAdapter ()->quote ( );
    $select->where (”  = “,  ); 
    OR (If you are using the question mark after equal to sign)
    $select->where (”  = ? “, ); 

     

  50. CSS Tutorial

  51. Question 29. How Can You Get A Module Name In Bootstrap File?

    Answer :

    $router = new Zend_Controller_Router_Rewrite();
    $request = new Zend_Controller_Request_Http();
    $router->route($request);
    $moduleName = $request->getModuleName();
  52. CakePHP Interview Questions

  53. Question 30. What Is A Framework?

    Answer :

    In software development, a framework is a defined support structure in which another software project can be organized and developed.

    • An abstract design
    • Set of common functionality
    • Developed for a particular domain
  54. Question 31. Why Should We Use Framework?

    Answer :

    Framework is a structured system

    • Source codes become more manageable
    • Easy to extend features
    • Rapid application development.
  55. WordPress Tutorial

  56. Question 32. What Is Bootstrapping?

    Answer :

    Many PHP applications funnel server requests into a single (or few) PHP source file that sets up the environment and configuration for the application, manages sessions and caching, and invokes the dispatcher for their MVC framework. They can do more, but their main job is to take care of the consistent needs of every page of a web application.

    In our Blueprint for PHP Applications, we will have a core bootstrapper that receives all dynamic requests for an application and applies a template for application behavior that we can later extend. It will allow us to later customize the functionality for each unique application.

  57. CodeIgniter Interview Questions

  58. Question 33. What Is Zend Engine?

    Answer :

    Zend Engine is used internally by PHP as a compiler and run time engine. PHP Scripts are loaded into memory and compiled into Zend opcodes.

  59. Linux Interview Questions

  60. Question 34. What Is Zend Engine In Php?

    Answer :

    Zend engine is like a virtual machine and is an open source, and is known for its role in automating the web using PHP. Zend is named after its developers Zeev and Aandi. Its reliability, performance and extensibility has a significant role in increasing the PHP’s popularity. The Zend Engine II is the heart of PHP 5. It is an open source project and freely available under BSD style license.

  61. Question 35. What Is Routing And How It’s Work?

    Answer :

    Zend_Controller_Router_Rewrite is the standard framework router. Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request. This values of the module, controller, action and other parameters are packaged into a Zend_Controller_Request_Http object which is then processed by Zend_Controller_Dispatcher_Standard. Routing occurs only once: when the request is initially received and before the first controller is dispatched.

    Zend_Controller_Router_Rewrite is designed to allow for mod_rewrite-like functionality using pure PHP structures. It is very loosely based on Ruby on Rails routing and does not require any prior knowledge of webserver URL rewriting. It is designed to work with a single Apache mod_rewrite rule.

  62. Question 36. What Are Plugins In Zend Framework?

    Answer :

    • Triggered by front controller events
    • Events bookend each major process of the front controller
    • Allow automating actions that apply globally

    Creating Plugins:

    • Extend Zend_Controller_Plugin_Abstract
    • Extend one or more of the event methods.
  63. Drupal Interview Questions

  64. Question 37. Zend_cache Provides A Generic Way To Cache Any Data

    Answer :

    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.

  65. Question 38. How To Include Css From Controller And View In Zend?

    Answer :

    From within a view file: $this->headLink()->appendStylesheet(‘filename.css’);
    From within a controller: $this->view->headLink()->appendStylesheet(‘filename.css’);
    And then somewhere in your layout you need to echo out your headLink object:
    headLink();?>

  66. Question 39. How Do You Protect Your Site From Sql Injection In Zend When Using Select Query?

    Answer :

    You have to quote the strings,

    $this->getAdapter ()->quote ( );
    $select->where ( ” = “, );
    OR (If you are using the question mark after equal to sign)
    $select->where ( ” = ? “, );

  67. Question 40. What Is Mvc?

    Answer :

    • Model-View-Controller development pattern.
    • MVC is a software approach that separates application logic from presentation.

    Model:The “stuff” you are using in the application data, – web services, feeds.

    View : The display returned to the user.

    Controller: Manages the request environment, and determines what happens.

  68. Magento Interview Questions

  69. Question 41. Features Of Mvc In Zend Framework?

    Answer :

    • Declare custom routing rules Not limited to “controller/action/param” format
    • Optional Controller Plugins, Action Helpers, and View Helpers ErrorHandler plugin handles exceptions, 404 errors, etc. FlashMessenger, Redirector, ViewRenderer helpers Output common HTML elements in views
    • Extensible interfaces Write your own plugins and helpers.
  70. Question 42. Why Can’t Zend_form Render My File Element Without Errors?

    Answer :

    The file element needs a special file decorator, which is added by default. When you set your own decorators for file elements, you delete the default decorators.

    For example:

    $element->setDecorators(array(
    array(‘ViewHelper’),
    array(‘Errors’)
    ));

    You should use a File decorator instead of the ViewHelper for the file element, like so:

    $element->setDecorators(array(
    array(‘File’),
    array(‘Errors’)
    ));
  71. MVC Framework Interview Questions

  72. Question 43. How Can I Customize The Appearance Of Forms Generated By Zend_form?

    Answer :

    You’re probably looking for decorators. All forms and form elements in Zend_Form use decorators to render their output.

  73. Question 44. Why Does The Zend Framework Project Have A Cla At All?

    Answer :

    The CLA protects all users including individuals, small and medium businesses, and large corporations. By having a CLA in place, we mitigate the risk that companies who claim intellectual property infringement may demand royalties or fees from users of Zend Framework, whether individuals or companies. This is especially important for companies basing their business or products on Zend Framework. The Zend Framework CLA helps to ensure that code and other IP in Zend Framework remains free.

  74. Question 45. Should I Sign An Individual Cla Or A Corporate Cla?

    Answer :

    If you are contributing code as an individual- and not as part of your job at a company- you should sign the individual CLA. If you are contributing code as part of your responsibilities as an employee at a company, you should submit a corporate CLA with the names of all co-workers that you foresee contributing to the project.

  75. Question 46. What Is Front Controller?

    Answer :

    It used Front Controller pattern. zend also use singleton pattern.

    • routeStartup: This function is called before Zend_Controller_Front calls on the router to evaluate the request.
    • routeShutdown: This function is called after the router finishes routing the request.
    • dispatchLoopStartup: This is called before Zend_Controller_Front enters its dispatch loop.
    • preDispatch: called before an action is dispatched by the dispatcher.
    •  postDispatch: is called after an action is dispatched by the dispatcher.

     

  76. Question 47. I Want To Use A Sql Function Or Perform Calculations In A Statement Fm Generating With Zend_db_select. How Can I Do This?

    Answer :

    Actually, by default. if your expression includes parentheses, Zend_Db_Select will cast the statement appropriately. However, if it does not, or you are having problems, you can use Zend_Db_Expr to explicitly create the expression:

    * Build the SQL:
    SELECT p.product_Jd p.cost 1.08A5 costp/us_tax
    * FROM “products”AS p
    $se/ect $db->se/ect()
    ->from(array(‘p’=>‘products’),
    array(
    ‘product_id’,
    ‘cost_p/us_ tax’>new Zendj2b_Expr(’p.cost*1.08),
    ));
  77. Question 48. About Zend Framework?

    Answer :

    Extending the art & spirit of PHP, Zend Framework Is based on simplicity, object-oriented best practices, corporate Friendly licensing, and a rigorously tested agile codebase, Zend Framework Is Focused on building more secure, reliable, and modern Web 2.0 applications &web services, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo. Flickr as well as API providers and cataloguers like Strike iron and ProgrammableWeb.

  78. Question 49. What Do I Have To Do To Contribute To Zend Framework?

    Answer :

    The only requirement for contributing to Zend Framework is submitting our either our Individual Contributors License Agreement ((LA) or our corporate CLA. Once you have signed the CL you can visit our contributors wiki to get started.

    We strongly recommend you read and understand the terms of our New BSD License-style license, under which all parts of Zend Framework are licensed, all contributions inclusive.

  79. Question 50. What Is The Difference Between Zend_auth And Zend_aci?

    Answer :

    Zend Auth is used for authenticating users with variety of authentication methods, including LDAP, OpeniD, and HTTP, Authentication is the process of verifying that the provided credentials are valid for the system. By authenticating to your system, your users can prove that they are who they say they are. For more information on Zend Framework’s authentication implementation, see the Zend_Auth documentation.

    Zend_Acl is an implementation of Access Control List (ACL) authorization. Generally speaking, ACLs are lists of roles that are authorized to perform a particular operation on specific resources in your system. Zend_AcI can support advanced rule definitions with features such as multiple inheritance for roles and assertions for conditional rules. For more information on Zend_AcI, see the Zend_AcI documentation.

    Zend Auth and Zend_AcI can be used together to build very sophisticated security systems: first the user confirms their Identity with Zend_Auth, then this Identity is used to assign one or more Zend_AcI roles to the user for authorization to use or modify resources in the system.

  80. Question 51. What Version Of Php Is Zend Framework 2 Based On?

    Answer :

    Zend Framework 2 Is based on PHP 5.3. We expect to add support For PHP 5.4 once it starts to be adopted by the PHP community.

  81. Question 52. I’m Starting A New Project – Which Version Of Zend Framework Should I Use?

    Answer :

    If the project will complete mid-2012 or later, start using Zend Framework 2! The current beta 3 is a great opportunity to begin acquainting yourself with the main features, and the feature-complete beta 4 and GA releases will follow quickly.

  82. Question 53. Does This Mean That Zend Framework 1 Is About To Be End-of-lifed?

    Answer :

    Definitely not! We currently plan to fully support Zend Framework I until at least early 20 14, including maintenance and security updates.

  83. Question 54. What’s The Release Schedule For Zend Framework 2?

    Answer :

    Zend Framework 2 Beta 3 is the current release. There will be a feature-complete beta in spring 2012. Official general availability is planned for summer 2012.

  84. Question 55. What New Features Will I Find In Zend Framework 2?

    Answer :

    Some highlights:

    • An entirely re-written event-driven MVC layer
    • Dependency injection support
    • A powerful module management system
    • An EventManager, for writing event-driven systems, as well as for creating cut points in your software for introducing cross-cutting concerns.
    • A new view layer, architected around analyzing the request and generating a suitable response, be it plain old HTML, or Atom feeds or JSON.
  85. Question 56. A New Zend Framework Release? Why?

    Answer :

    We’ve examined ZFI from the view point of its architecture, as well as the use cases developers have adopted. In many cases, we simply cannot support existing use cases, or the architecture needs to change in order to do so. Additionally, since ZFI grew very organically, there are many places where similar solutions to similar problems are inconsistent, leading to difficulty educating developers. In Zend Framework 2 we’ve used a consistent set of coding patterns and practices and we’ve taken into account the generally acknowledged best practices for writing efficient reliable, and high-performing software.

  86. Question 57. What Services Are Available From Zend Technologies For Zend Framework?

    Answer :

    Zend Technologies provides a comprehensive set of services for Zend Framework, including:

    • Support
    • Training
    • Consulting
    • Certification
  87. Question 58. I’ve Tried Sending An ‘unsubscribe’ Mail To All Zf Mailing Lists, But I’m Still Getting Messages From These Lists. What Do I Have To Do To Stop Getting These Mails?

    Answer :

    There is an ‘fw-all’ list that aggregates all other lists besides 1w-announce, fw- general, fw- docs, and fw- svn. Please try sending an email to IW-all-subscribe@lists.zend.com to make sure you’re not subscribed to this list Also, please ensure that you mail all unsubscribe requests from the account that you subscribed with. You may be receiving list traffic on a different account if you have set up a mail forward from the original subscription account.

  88. Question 59. Why Are Client Libraries For Web Services Such As Akismet, Amazon, Audioscrobbler, Delicious, Flickr, Nirvanix, Simply, Strikeiron, And Yahoo! Part Of The Zend Framework Standard Library?

    Answer :

    Zend Framework has been designed to solve the most common problems in web application development. Web services are a big part of today’s web development environment, So much so that many of our users consume our web service clients for services such as Amazon ECS, Akismet, and ReCaptcha before adopting more infrastructure-oriented components such as Zend_Registry and Zend_Log. Because these web services play such an important role in today’s web applications, we consider them ‘first-class citizens’ in ZF.

  89. Question 60. Can I Use Zend_search_lucene To Search My Java Lucene-generated Indexes?

    Answer :

    Yes! In fact, the Zend Framework site uses Zend_Search_Lucene with indexes created by our java developer tools to provide site-wide search.

  90. Question 61. What Is Lucene?

    Answer :

    Lucene is a high-performance, full-featured text search engine that utilizes an open, binary format for storing search indexes and a standardized query format for querying against the indexes. Lucene was originally written in java as part of the Apache project. Zend_Search_Lucene is a PHP implementation that provides full binary compatibility with Java Lucene.

  91. Question 62. I’m Using Apache, And Passing Urlencoded Slashes Via $_get Or As Url Parameters – And I’m Getting 4o4s’

    Answer :

    Apache by default disallows urlencoded slashes (I.e., %2F”) In IJRL path parts or the query string. This feature can be disabled by enabling the “AllowEncodedS lashes’ directive:

    AllowEncodedSlashes On

    However, this directive must be set at either a seiver-wide (httpd.conf) or virtual-host level.

  92. Question 63. I’m Using The Contextswitch Or Ajaxcontext View Helper And Receiving An Exception Indicating The Error.ajax.phtml View Script Is Missing What Am I Doing Wrong?

    Answer :

    ContextSwitch makes the assumptions that

    1. you are not calling _forward() and
    2. that your application code will not throw an exception.

    If you see the above error; your code is throwing an exception – but the context is still in play, and the ViewRenderer is simply trying to load a view script for the current context from the ErrorController.

    The easiest way to fix the situation is to have the ErrorController::errorAction() redefine the view script suffix, as follows:

    class ErrorController extends Zend_Controller_Action
    {
    public function errorAction()
    {
    $this->_helper->viewRenderer->setViewSuffix(’phtml’);
    //…
    }
    }
  93. Question 64. How Can I Retrieve The View Object Within A Plugin Or Arbitrary Code?

    Answer :

    ZF uses an action helper called the ViewRenderer by default. This action helper instantiates and stores a Zend_view object which is subsequently injected into other objects. The view object is stored in the ViewRenderer’s view property. You can get the ViewRenderer instance, and thereby the view instance, with the Action Helper broker:

    $vsewRenderer Zend,, Conrroller,,A ction_HelperBroke::getStaticHelper(viewRenderer);

    $view =$viewRenderer-->view

    However, if you’re accessing the view early in the dispatch process- before an action is actually dispatched, for example- then you may need to initialize the view first

    if (!isset($viewRenderer->view))
    {
    $viewRendere-->intViewO();
    }
    $vi ew = Svi ewRenderer-- >view;

    If you are using and have already initialized Zend_Layout, you can access the view object much more succinctly:

    $view = Zend_Layo ut::getMvcInstance()-- >getView();

    This proxies to the ViewRenderer and performs all of the steps above for you.

  94. Question 65. How Can I Debug Zend_date In A Simple Way?

    Answer :

    When you think that you are getting wrong output from Zend_Date then it’s often needed to see what Zend_Date really uses internally.

    Well., a var_dump of Zend_Date is not really helpful,l but you could simply use getIso(). This format has all date inform actions

    available:
    $date- >getIso(); I/could return 2009-10-21 T!5:OO:O2O 1:00’

    Note that using toString() and outputting only parts of a date does not show all needed information’s. There could be a wrong used timezone, or a DST change which is suppressed by toString() but shown with getIso().

  95. Question 66. Why Are My Dates Formatted Wrong? Why Do I Get The False Year Value?

    Answer :

    When using own formats in your code you could come to a situation where you get for example 29.1 2.2009, but you expected to get 29.1 2.2008.

    There is one year difference: 2009 instead of 2008. You should use the lower cased year constant. See this example:

    $date- >toString(dd.MM.yy);

    Note the lower cased “y” which makes the difference and outputs the real year.

  96. Question 67. How Can I Use The Same Locale Everywhere?

    Answer :

    With ZF 1.7 an application wide locale is supported. You can do the following in your bootstrap file:

    $locale = new Zend_Locale(’en’);
    Zend_Registry::set(’Zend_Locale $locaIe;

    From now on, all locale aware components will use your locale object stored in the registry as long as you don’t give another one manually.

  97. Question 68. How Can I Make All I’ll 8n-aware Components Aware Of My Zend_translate Object?

    Answer :

    A variety of components are translation aware (i.e., accept Zend_Translate objects), including:

    Zend_View_Helper_Translate
    Zend_Validate_*
    Zend_Form

    To have them all use the same Zend_Translate instance, simply place it in the registry with the key “Zend_Translate”:

    Zend_Registry::set(‘Zend_Translate’, $translate);
  98. Question 69. How Can I Detect If An Optional File Has Been Uploaded?

    Answer :

    The receive() method will return true for file elements that are not required. The reason is that you said “the file can be omitted, and that’s ok for me”. The receive() method will return false only in the event of a failure.

    Still there are several ways to detect if a file has been uploaded or not:

    • Use isUploaded which returns a boolean
    • Use getFileName which returns null in this case (note that you must use the latest release for this behavior)
    • Use getFileInfo which will have an empty ‘file’ key and the flag ‘isUploaded’ set to false
  99. Question 70. How Can I Add Extra Html (such As A Link) To My Form Element?

    Answer :

    This can easily be done using decorators. For instance using the Description decorator. It is important to note though that you will need to turn off escaping for the output of the decorator:

    $element->setDecorators(array(
    array(‘ViewHe/per’),
    array(‘Description’,array(‘escape’, false)),
    array(‘Errors’),
    array(‘HtmlTag’, array(‘tag’=>’dd’)),
    arrar(‘Lable’, array(‘tag’=>’dt’)),
    ));

    Now, you can use the following to add extra HTML to the element:

    $element->setDescription(’This contains HT%1L that will actually be parsed by the browser, not escaped’);

  100. Question 71. I Want To Use A Sql Function Or Perform Calculations In A Statement I’m Generating With Zend_db_select. How Can I Do This?

    Answer :

    Actually, by default, If your expression Includes parentheses, Zend Db Select will cast the statement appropriately. However, If It does not, oryou are having problems, you can use Zend_Db_Exprto explicitly create the expression:

    /‘ Build the SQL:
    * SELECT p.”product_jd”, p.cost * 1.08 AS cost_plus_tax
    * FROM “products “ AS p
    $select = $db-->select()
    ->from(array(’p’ =>’products’),
    array(
    product_id’,
    ‘cost_plus_tax’ => new Zend_Db_Expr(‘p.cost * l.08’),
    ));
  101. Question 72. I’ve Submitted The Cla Now How Can I Get Started Contributing To Zend Framework?

    Answer :

    There are lots of ways to contribute to Zend Framework. Many major features are contributed to ZF through our proposal process. Most code contributors also commit bug fixes and tests. Another valuable form of contribution is manual translation and other forms of documentation. Contributors may also invest their time in updating the wiki or adding, commenting on, and voting on Issues in our Issue tracker. No matter how you plan to contribute, the best place to get started is our contributor guide.

  102. Question 73. What Kind Of Contribution Requires That I Submit A Cla? And What Kind Of Contribution Can I Make Without Submitting A Cla?

    Answer :

    You must sign a (LA before Zend Framework can accept any content that constitutes Intellectual property. This Includes anything that could carry a copyright or be patented. This includes code, patches, tests, documentation, and even proposals submitted on our wiki. You do not need to submit a CIA to report a bug or make a feature request in our issue tracker, or to ask a question on the mailing lists, You can Include code In emails to the mailing lists to Illustrate your words, but your code cannot be incorporated into Zend Framework unless it Is submitted under the terms of the CLA.