Shared Flashcard Set

Details

Zend Framework 1.5 Certification
PHP / Zend Framework 1.5 Cerfication Exam
141
Computer Science
Professional
01/10/2011

Additional Computer Science Flashcards

 


 

Cards

Term
What is Zend_Auth?
Definition
Authentication API for verifying a user's identity against some predetermined criteria
Term
How is Zend_Auth used?
Definition
Call static getInstance() and use an authentication service adapter such as LDAP, RDBMS, etc. Then, call functions such as isValid() and getIdentity().
Term
What is Zend_Auth Identity Persistence?
Definition
Use of a storage class (Zend_Session by default) that retains the identity across requests in accordance with PHP session configuration. Custom classes implement Zend_Auth_Storage_Interface and pass it to Zend_Auth::setStorage().
Term
What does the Zend_Auth adapter authenticate() method return?
Definition
Instance of Zend_Auth_Result with functions such as isValid(), getCode(), getIdentity(), getMessages().
Term
What are some Zend_Auth adapters?
Definition
Zend_Auth_Adapter_Ldap
Zend_Auth_Adapter_DbTable
Zend_Auth_Adapter_Http
Zend_Auth_Adapter_OpenId
Term
What does Zend_Auth adapter's isValid() return?
Definition
TRUE if and only if the result represents a successful authentication attempt.
Term
What does Zend_Auth adapter's getCode() return?
Definition
A constant identifier for confirming success or determining the type of authentication failure.
Term
What does Zend_Auth adapter's getIdentity() return?
Definition
The identity of the authentication attempt, such as the username.
Term
What does Zend_Auth adapter's getMessages() return?
Definition
An array of messages regarding a failed authentication attempt.
Term
What is Zend_Acl?
Definition
Access control list component to handle authorizing access; privileges management.
Term
What are a couple ways to integrate Zend_Acl into your MVC application?
Definition
Action Helper
or
Front Controller Plugin
Term
What do you call combining the process of authentication and authorization?
Definition
"Access Control"
Term
What is a Zend_Acl "Resource"?
Definition
An object with controlled access.
Term
What is a Zend_Acl "Role"?
Definition
An object that requests access to a resource.
Term
What two functions are used to specify Zend_Acl access control rules?
Definition
Zend_Acl::allow()
and
Zend_Acl::deny()
Term
When will Zend_Acl::isAllowed() throw an exception?
Definition
When it is called against a Role or Resource that was not previously added to the ACL results.
Term
How is a Zend_Acl created?
Definition
require_once 'Zend/Acl.php'
$acl = new Zend_Acl();
Term
How is a Zend_Acl resource created?
Definition
Implement the Zend_Acl_Resource_Interface or extend Zend_Acl_Resource. Should have the single method getResourceId().
Term
How is a Zend_Acl role created?
Definition
Implement the Zend_Acl_Role_Interface or extend Zend_Acl_Role. Should have the single method getRoleId().
Term
How does Zend_Acl resource inheritance work?
Definition
Queries on a specific resource with automatically search the hierarchy for rules assigned to its parent resources. Can inherit from only one parent resource.
Term
How does Zend_Acl role inheritance work?
Definition
Multiple inheritance is possible. For rule conflicts the first rule found via query wins.
Term
What interface and method provides support for implementing role or resource access rules based on conditions to be met?
Definition
Use the Zend_Acl_Assert_Interface and the assert() method.
Term
Zend_Acl supports ______ inheritance among Resource objects.
Definition
Single
Term
True or False: Zend_Auth throws an exception upon an unsuccessful authentication attempt due to invalid credentials (e.g., the username does not exist).
Definition
False
Term
In the Zend coding standard, should you use the closing tag "?>" for files that contain only PHP code?
Definition
Never
Term
In the Zend coding standard, how should code be indented?
Definition
4 spaces, not tabs
Term
In the Zend coding standard, should all PHP files have the extension .php?
Definition
Yes, except view files.
Term
In the Zend coding standard, what should accessors for objects be prefixed with?
Definition
Either "get" or "set"
Term
In the Zend coding standard, when is the only time a variable must begin with an underscore?
Definition
Private or protected class member variables
Term
In the Zend coding standard, where should the concatenation operator be placed when breaking long lines?
Definition
Directly under the "=" operator.
Term
In the Zend coding standard, which is valid: "elseif" or "else if"?
Definition
else if
Term
True or false: In the Zend coding standard, all switch statements must have a default case.
Definition
True
Term
In Zend coding standard, what documentation format should doc blocks be compatible with?
Definition
phpDocumentor
Term
In Zend coding standard, what tags should exist in the top of the PHP files?
Definition
@copyright, @license, @version, @link, and @since
Term
In Zend coding standard, what tags must every class-level docblock contain?
Definition
@copyright, @license, @version, @link, @since, and @deprecated
Term
Is the following class name valid?: My_Foo_123
Definition
Yes
Term
The filename "Zend/Db/Table.php" must map to the class name ______.
Definition
Zend_Db_Table
Term
What is the base class used for connecting PHP applications to a RDBMS?
Definition
Zend_Db_Adapter_Abstract
Term
How can you dynamically load the Adapter class on demand?
Definition
Use the static method Zend_Db::factory() which utilizes Zend_Loader::loadClass()
Term
What parameters can be passed to the Zend_Db::factory() method?
Definition
Either a Zend_Config object or an associative array.
Term
With Zend_Db, when is a connection to the database first created?
Definition
Triggered the first time a query is executed, or when the getConnection() method is called.
Term
Suppose you have:
$db = Zend_Db::factory('Pdo_Mysql', $params)
$sql = 'SELECT * FROM bugs WHERE bug_id = ?';
How would you execute this query using the bug_id = 2?
Definition
$result = $db->fetchAll($sql, 2)
Term
What method should be used to change the result structure of Zend_Db's fetchAll()? What are the valid mode constants?
Definition
Use the setFetchMode() method. Constants are Zend_Db::FETCH_ASSOC, Zend_Db::FETCH_BOTH, Zend_Db::FETCH_COLUMN, Zend_Db::FETCH_NUM, Zend_Db::FETCH_OBJ
Term
What are the parameters to Zend_Db insert()?
Definition
First parameter is a string naming the table, and second is an associative array mapping column names to data values.
Term
What is the difference between Zend_Db quote() and quoteInto()?
Definition
The quote() method escapes a given string. The quoteInto() method interpolates using the placeholder symbol (?) and a value.
Term
What method is used to quote RDBMS identifiers?
Definition
Use the quoteIdentifier() method.
Term
What is returned by the Zend_Db query() method?
Definition
A statement object Zend_Db_Statement
Term
How are named parameters used with the Zend_Db_Statement?
Definition
In the query string, use the string identifier preceded by a colon character (:) and pass the bind values in an associative array.
Term
How do you execute a statement object with two placeholders, say, "A" and 123?
Definition
$stmt->execute("A", 123);
Term
Name 4 different SQL statement types that can be used with fetch() in a loop.
Definition
SELECT, SHOW, DESCRIBE, EXPLAIN
Term
What are some fluent methods of the Zend_Db_Select object?
Definition
where(), order(), from()
Term
Using the Zend_Db_Select fluent interface, how would you build the following query:
SELECT b."book_id" AS TheBookID, b."book_name" FROM "books" as b
Definition
$select = $db->select()->from(array('b' => 'books'), array('TheBookID' => 'book_id', 'book_name'));
Term
Using the Zend_Db_Select fluent interface, how would you build the following query:
SELECT b."book_id", b."book_name", a.* FROM "books" AS b JOIN "authors" AS a ON b.author_id = a.id
Definition
$select = $db->select()->from(array('b' => 'books'), array('book_id', 'book_name'))->join(array('a' => 'authors'), 'b.author_id = a.id');
Term
What class/interface should you extend or implement to build your own Zend_Db table class?
Definition
extend Zend_Db_Table_Abstract
Term
True or false: Zend_Db automatically uses the class name as the table name if $this->_name is not provided.
Definition
True
Term
What are the four setup methods that can be overridden in your Zend_Db table class?
Definition
_setupDatabaseAdapter(), _setupTableName(), _setupMetadata(), and _setupPrimaryKey()
Term
True or false: Zend_Db contains a factory() method by which you may instantiate a database adapter object.
Definition
True
Term
True or false: Zend_Db_Select supports querying columns containing expressions (e.g., LOWER(someColumn)).
Definition
True
Term
How could you add additional writers to a Zend_Log?
Definition
Use the addWriter() method.
Term
What is the second parameter to the Zend_Log log() method?
Definition
The integer priority level, such as Zend_Log::INFO.
Term
How would you write log data using Zend_Log to the PHP output buffer?
Definition
$writer = new Zend_Log_Writer_Stream('php://output');
$logger = new Zend_Log($writer);
Term
Name two Zend_Log formatter classes.
Definition
Zend_Log_Formatter_Simple and Zend_Log_Formatter_Xml
Term
How would you add a filter to a log such that only warnings and higher are logged?
Definition
$filter = new Zend_Log_Filter_Priority(Zend_Log::WARN);
$writer->addFilter($filter);
Term
What are the parameters to Zend_Debug::dump()?
Definition
First is the variable, second is the label, and third is whether or not to output.
Term
Which one of the following will not display the value of $var?
a. echo Zend_Debug::dump($var, 'far', false);
b. ob_start(); Zend_Debug::dump($var, 'var', false); ob_end_flush();
c. Zend_Debug::dump($var, 'var', true)
d. Zend_Debug::dump($var, 'var')
Definition
b
Term
Which formatters are provided with Zend_Log? (choose two)
a. Zend_Log_Formatter_Db
b. Zend_Log_Formatter_Simple
c. Zend_Log_Formatter_Text
d. Zend_Log_Formatter_Xml
Definition
b and d
Term
How would you chain a alphabetic filter and lowercase filter?
Definition
$filterChain = new Zend_Filter();
$filterChain->addFilter(new Zend_Filter_Alpha())->addFilter(new Zend_Filter_StringToLower());
Term
How would you create your own custom filter?
Definition
Create a class that implements Zend_Filter_Interfaces and has a filter() method.
Term
What does Zend_Validate getMessages() return?
Definition
An array of messages explaining the reason(s) for validation failure. The array keys identify string codes and array values are readable messages.
Term
What is the second parameter to the Zend_Validate::is() function?
Definition
The basename of the validation class relative to the Zend_Validate namespace.
Term
What are the 19 standard validation classes?
Definition
Alnum, Alpha, Barcode, Between, Ccnum, Date, Digits, EmailAddress, Float, GreaterThan, Hex, Hostname, InArray, Int, Ip, LessThan, NotEmpty, Regex, StringLength
Term
Which of the following could be used to validate an email address (choose 2):
a. Zend_Validate::is($email, 'EmailAddress');
b. Zend_Validate::isValid($email, 'EmailAddress');
c. $validator = new Zend_Validate_EmailAddress();
if ($validator->isValid($email)) {
// email appears to be valid
}
d. $validator = new Zend_Validate_EmailAddress($email);
if ($validator->isValid()) {
// email appears to be valid
}
Definition
a and c
Term
Which of the following can be used to produce:
Click
from the following input:
Click
a. Zend_Filter_StripTags
b. Zend_Text
c. Zend_Uri
d. Zend_View
Definition
a
Term
How do you set the form action and method using Zend_Form?
Definition
Use the setAction() and setMethod() methods.
Term
What are the 13 built-in Zend_Form elements?
Definition
button, hidden, image, radio, reset, submit, password, text, textarea, checkbox, multiCheckbox, select, multiselect
Term
What are the 4 ways to add elements to a form?
Definition
1. instantiate concrete elements and pass in these objects
2. pass in the element type
3. use createElement() and addElement()
4. use a configuration
Term
When using addValidator() by string type, how can you specify the validation class constructor arguments?
Definition
Passed in as an array as the third parameter.
Term
What are two ways to add validators to the chain?
Definition
Passing in a concrete validator instance or providing a validator name (short or fully qualified)
Term
What does the second parameter to addValidator() do?
Definition
If set to true, the particular validation failure will prevent later validators from firing.
Term
What does setAutoInsertNotEmptyValidator(false) do?
Definition
A 'NotEmpty' validator will not be prepended to the validator chain when the element is required.
Term
How would you add a prefix/path association loader where the class names begin with "My_" and the files are located in /usr/lib/php/My such as /usr/lib/php/My/Validate/Example.php with class My_Validate_Example and /usr/lib/php/My/Filter/Example.php with class My_Filter_Example?
Definition
addPrefixPath('My', '/usr/lib/php/My')
Term
What four decorators does Zend_Form_Element use to achieve output?
Definition
ViewHelper, Errors, HtmlTag, and Label
Term
How can you disable default decorators from loading during object initialization?
Definition
$element = new Zend_Form_Element('foo', array('disableLoadDefaultDecorators' => true));
Term
What are the 6 setters that cannot be set using the Zend_Config key method for Zend_Form_Element constructors?
Definition
setAttrib, setConfig, setOptions, setPluginLoader, setTranslator, setView
Term
How could you group together the elements 'firstName' and 'lastName' as the 'userInfo' group with Zend_Form?
Definition
$form->addDisplayGroup(array('firstName', 'lastName'), 'userInfo');
Term
True or false: The master form object will have awareness of the elements in sub forms.
Definition
False
Term
What are two ways of retrieving a sub form?
Definition
$subForm = $form->getSubForm('subform')
or
$subForm = $form->subform;
Term
True or false: By default, Zend_Forms will perform internationalization.
Definition
False
Term
How do you turn on i18n features in Zend_Form?
Definition
Zend_Form::setDefaultTranslator($translate)
Term
Validators used with Zend_Form should implement which component?
a. Zend_Form_Validator_Abstract
b. Zend_Validate_Abstract
c. Zend_Validate_Interface
d. Zend_Form_Validate_Interface
Definition
c
Term
Which of the following is NOT a valid mechanism for adding a decorator to an element?
a. $element->addDecorator(new Zend_Form_Decorator_ViewHelper());
b. $element->attachDecorator('ViewHelper');
c. $element->addDecorator('ViewHelper');
d. $element->addDecorator('ViewHelper', array('helper' => 'foo'));
Definition
b
Term
What are two commonly used Zend_Config adapters?
Definition
Zend_Config_Ini and Zend_Config_Xml
Term
What does the second parameter to Zend_Config_Ini's constructor do?
Definition
It specifies the specific ini section to be used.
Term
What do the return values of Zend_Version::compareVersion() mean?
Definition
0 means the version is the same, -1 if the specified version is older than the Zend Framework version, and +1 if the specified version is newer than the Zend Framework version.
Term
How can you use a new instance of Zend_Registry as the static instance?
Definition
Call Zend_Registry::setInstance($registry)
Term
What are the restrictions to the filename aregument to Zend_Loader::loadFile()?
Definition
The filename can only contain alphanumeric characters, hypens, underscores, or periods, and must not contain any path information.
Term
What is the second argument to Zend_Loader::loadClass()?
Definition
An array of the directories to search.
Term
In what order are plugin class paths searched for Zend_Loader_PluginLoader?
Definition
Searched in LIFO (Last In, First Out) order.
Term
True or false: Zend_Auth uses Zend_Session_Namespace to store some information associated with authenticated users.
Definition
True
Term
When does Zend_Session start the PHP session?
Definition
It will be started when the first session namespace is requested or when Zend_Session::start() is called.
Term
How do you reset the expiration time of data in Zend_Session?
Definition
Fetch the data into temporary variables, use the namespace to unset then, and then set the appropriate keys again.
Term
True or false: Zend_Config allows hierarchical and sectioned key-value pairs to exist in a single file.
Definition
True
Term
Given $tree = new Tree(array('type' => 'cedar')); and you wish to persist this object via Zend_Session, which call will put this object in the default namespace?
a. Zend_Session_Namespace::set('tree', $tree);
b. $sess = new Zend_Session_Namespace();
$sess->tree = $tree;
c. $sess = new Zend_Session();
$sess->tree = $tree;
d. $sess = Zend_Session::getInstance();
$sess->set('tree', $tree);
Definition
b
Term
What is the first parameter to the Zend_Locale constructor?
Definition
The method used to determine the correct locale, such as:
$locale = new Zend_Locale(Zend_Locale::BROWSER)
Term
What are the three automatic locales provided by Zend_Locale that do not belong to any language or region?
Definition
browser, environment, and auto
Term
How can Zend_Locale and Zend_Locale_Format performance be improved with caching?
Definition
Zend_Locale::setCache($cache) and Zend_Locale_Format::setOptions(array('cache' => $adapter))
Term
What does Zend_Locale's getDefault() method return?
Definition
Returns all default locales.
Term
What does the Zend_Locale getTranslationList() do?
Definition
Provides access to localized information of various types, without the need for translation.
Term
Name 8 built-in adapters for Zend_Translate.
Definition
Array, Tbx, Xliff, Csv, Tmx, XmlTm, Gettext, Qt
Term
What option is available to all Zend_Translate adapters and what does it do?
Definition
The 'clear' option; it decides if translation data should be added to existing content or not.
Term
What are three ways Zend_Translate finds translation sources?
Definition
1. When addTranslation() is used
2. When the 'scan' option is used with Zend_Translate and naming the language source directories
3. When the 'scan' option is used with Zend_Translate and use special filenames with the entire language file or parts of it.
Term
What five methods operate generically on Zend_Date?
Definition
add(), sub(), compare(), get(), and set()
Term
What does the Zend_Date method's $parts parameter do?
Definition
A constant can be used in order to select a specific part of a date or to indicate the date format used or desired.
Term
What method is used to check if a date string is a real date?
Definition
Zend_Date::isDate()
Term
How is the Zend_Currency locale set?
Definition
If no parameters are used, it will use the actual locale and it's related currency. If it can't be detected, it throws an exception.
Term
What method is used to convert an existing value to a currency formatted output?
Definition
Zend_Currency::toCurrency()
Term
What method is used to convert localized numbers to normalized numbers?
Definition
Zend_Locale_Format::getNumber()
Term
What is the first parameter to Zend_Currency::toCurrency()?
Definition
An array with options that can set another format or currency representation.
Term
What are three ways of initiating the Translate View Helper?
Definition
1. Registered through a previously registered instance in Zend_Registry
2. Afterwards through the fluent interface
3. Directly, through initiating the class.
Term
What method of Zend_Locale will check if a given string is a locale?
Definition
Zend_Locale::isLocale()
Term
Which Zend_Date constant should you use when you want to have the date formatted for an RSS feed?
a. Zend_Date::RSS_FEED
b. Zend_Date::RSS2
c. Zend_Date::RSS
d. Zend_Date::RSSFEED
Definition
c
Term
What Zend_Mail method returns an array with all recipient email addresses that were added prior to the method call?
Definition
getRecipients()
Term
How do you set the MIME content type to text/html when using Zend_Mail?
Definition
Set the body using the method setBodyHtml() instead of setBodyText()
Term
What Zend_Mail method is used to attach files to e-mails?
Definition
createAttachment()
Term
What is the return value of Zend_Mail::createAttachment()?
Definition
a Zend_Mime_Part object that can be used to modify it's MIME attributes before sending the mail
Term
What is the first parameter to Zend_Mail::send()?
Definition
You can pass a different transport.
Term
What are the three ways recipients can be added to Zend_Mail?
Definition
addTo(), addCc(), and addBcc()
Term
What default encoding mechanism is used for Text/HTML bodies and for attachments?
Definition
The 'quotedprintable' mechanism and base64 for attachments.
Term
What are four mail storage systems that Zend_Mail can read from?
Definition
Mbox, Maildir, Pop3, and IMAP
Term
How would you read message #123 from a Mbox file located at /var/mail/inbox?
Definition
$mail = new Zend_Mail_Storage_Mbox(array('filename' => '/home/test/mail/inbox'));
$message = $mail->getMessage(123);
Term
How would you read the 'received' message header as an array from a Zend_Mail_Storage_Mbox?
Definition
$received = $message->getHeader('received', 'array');
Term
True or false: Zend_Mail content can be fetched using getContent(), even if the mail has a multi-part message.
Definition
False
Term
What two methods are useful for multi-part Zend_Mail messages?
Definition
isMultipart() and getPart()
Term
What Maildor and IMAP flags can be used for checking if a message is seen or is recent?
Definition
Zend_Mail_Storage::FLAG_SEEN and
Zend_Mail_Storage::FLAG_RECENT
Term
What two classes handle local storage Zend_Mail folders?
Definition
Zend_Mail_Storage_Folder_Mbox and Zend_Mail_Storage_Folder_Maildir
Term
What interface does Zend_Mail_Storage_Folder implement?
Definition
the RecursiveIterator interface
Term
What three methods are useful for dealing with changing Zend_Mail folders?
Definition
isSelectable(), getSelectedFolder(), and selectFolder()
Term
What magic methods do Zend_Mail_Storage_Folder_Maildir implement?
Definition
__sleep() and __wakeup()
Term
What two classes should you extend to add features to the Pop3 protocol?
Definition
Zend_Mail_Protocol_Pop3 and Zend_Mail_Storage_Pop3
Term
With quotas enabled which methods might fail because you're over quota? (choose TWO)
a. appendMessage()
b. removeMessage()
c. createFolder()
d. getMessage()
Definition
a and b
Term
How would you connect to a Pop3 server using TLS?
a. $mail = new Zend_Mail_Storage_Pop3_Tls(array('host' => 'example.com', 'user' => 'test'));
b. $mail = new Zend_Mail_Storage_Pop3(array('host' => 'example.com', 'user' => 'test', 'ssl' => true));
c. $mail = new Zend_Mail_Storage_Pop3(array('host' => 'example.com', 'user' => 'test', 'ssl' => 'tls'));
d. $mail = new Zend_Mail_Storage_Pop3(array('host' => 'example.com', 'user' => 'test', 'tls' => true));
Definition
c
Supporting users have an ad free experience!