Zend PHP5 certification Exam study review 12: supplementary III
Ok, this is the last part of my reviews. This post listed some WEIRD and STRANGE questions I found in the phparch’s simulator exam. You may think these are some advanced features of the PHP5 language, but some of them are actually mention in the GUIDE also. However, some of the questions, I found that there maybe some errors in the question itself; in this case, I marked with the “*” in front of the question. Therefore, some of the answer I gave maybe not right, or maybe I get the meaning of the questions wrong. So, if you have any comment on this post, please feel free to comment or send me a message. Thanks!
What three special methods can be used to perform special logic in the event a particular accessed method or member variable is not found?
__get($name)
__set($set, $val)
__call($method, $args)
__get() and __set() are called when accessing or assigning an undefined object property, while __call() is executed when calling a non-existent method of a class.
* When writing portable database code using PDO, what is the PDO::ATTR_CASE attribute useful for?
Force column names to a specific case specified by the PDO::CASE_* constants.
*XPath
<?php
$dom = new DomDocument();
$dom->load(‘test.xml’);
$xpath = new DomXPath($dom);
DOMXPath->query() — Evaluates the given XPath expression
$nodes = $xpath->query(???????, $dom->documentElement);
echo $nodes->item(0)->getAttributeNode(‘bgcolor’)->value
. “\n”;
?>
http://www.w3schools.com/xpath/xpath_syntax.asp
*What should go in the ??????? assignment below to create a Zlib-compressed file foo.gz with a compression level of 9?
<?php
$file = ‘????????’;
$fr = fopen($file, ‘wb9′);
fwrite($fr, $data);
fclose($fr);
?>
*What should be replaced in the string ??????? below to open the archive myarchive.gz located in the document root of the www.example.com server and decompress it?
<?php
$file = ‘???????’;
$fr = fopen($file, ‘rb’);
$data = “”;
while(!feof($fr)) {
$data .= fgets($fr, 1024);
}
fclose($fr);
?>
compress.zlib://
*In the event of a PDOException, $info is set with the contents of the $errorInfo property of the exception
an array of error information about the last operation performed by this database handle. The array consists of the following fields:
| Element | Information | 0 | SQLSTATE error code (a five-character alphanumeric identifier defined in the ANSI SQL standard). | 1 | Driver-specific error code. | 2 | Driver-specific error message. |
|---|
*In databases that do not support the AUTO_INCREMENT modifier, you must use a LAST_INSERT_ID(id+1) instead to auto-generate a numeric incrementing key.
*Are following incorrect? Only two are wrong, not four.
a. function c(MyClass $a = new MyClass())
b. function d($a = null)
c. function e(&$a = 30)
d. function a(&$a = array(10,20,30))
e. function b($a = (10 + 2))
b,c,d.
*How does one create a cookie which will exist only until the browser session is terminated?
bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly ]]]]]] )
If $expire set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).
*If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?
PHP’s Regular Expression Functions (POSIX Extended). regex
POSIX
ereg functions
Perl-style
preg functions.
Perl-compatible syntax using the PCRE functions. These functions support non-greedy matching, assertions, conditional subpatterns, and a number of other features not supported by the POSIX-extended regular expression syntax.This extension maintains a global per-thread cache of compiled regular expressions (up to 4096).
*Which of the following extensions are no longer part of PHP 5 and have been moved to PECL?
w32api, mysql, PDF, ICONV
*Name three new extensions in PHP 5
SimpleXML,PDO, tidy, MySQLi, sqlite, soap
(hash,Reflection,libxml2-based DOM and XSL extensions DOMXML)
*Which of the following SQL statements will improve SQLite write performance?
PRAGMA locking_mode = “Row”;
PRAGMA count_changes = Off;
PRAGMA default_synchronous = Off;
PRAGMA default_synchronous = On;
PRAGMA locking_mode = “Table”;
*What kind of information is acquired when profiling a PHP script?
timer, functions executed
*The method used to create a new node to be added into an XML document using DOM is the DOMDocument->createElement() method
<?php
function func(&$arraykey) {
return $arraykey; // function returns by value!
}
$array = array(‘a’, ‘b’, ‘c’);
foreach (array_keys($array) as $key) {
$y = &func($array[$key]);
$z[] =& $y;
}
var_dump($z);
?>
// compare to $z[] = ['c', 'c', 'c'];
*Implementing your own PDO class requires which steps from the list below?
extending PDO;
extending PDOStatement;
PDO->setAttribute(PDO::ATTR_STATEMENT_CLASS=>array(string classname, array(mixed constructor_args))
* The implode() function is used to convert an array into a string, maintaining your ability to return the string into an array
Which of the following functions allow you to introspect the call stack during execution of a PHP script?
array debug_backtrace ( void )
generates a PHP backtrace.
Thank you for reading this post. You can now Read Comments (23)
Post Info
This entry was posted on 26 January 2008 8:49 PM and is filed under php tagged with:Technology,web development,zend certification,phpYou can follow any responses to this entry through the Comments Feed. You can Leave A Comment , or A Trackback .
Previous Post: Zend PHP5 certification Exam study review 11: supplementary II »
Next Post: The philosophy of life »
- The meaning of history
- What is the best system to set up and run a web site?
- I want every Chinese read George Orwell 1984!
- I think we should trying to get to know more each other’s history.
- Google’s customer service, what would Google do?
- Get Start a new eZ Publish project – Part II
- Get Start a new eZ Publish project – Part I
- Google Wave, got in
- The purpose of study Economics
- Music, the “Lifeline”
chinese














4 February 2008 3:55 AM
Question:
If regular expressions must be used, in general which type of regular expression functions available to PHP is preferred for performance reasons?
I think the answer is: preg_*
I found it in php manual:
Note: preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().
http://uk3.php.net/ereg
5 April 2008 5:14 PM
Hello,
It’s no so obvious (as many other questions in MockExams, heh).
Page 89-90 of Zend PHP5 Certification Study Guide:
“Perl Compatible Regular Expressions (normally abbreviated as “PCRE”) offer a very
powerful string-matching and replacement mechanism that far surpasses anything
we have examined so far.
Regular expressions are often thought of as very complex—and they can be at
times. However, properly used they are relatively simple to understand and fairly
easy to use. Given their complexity, of course, they are also much more computationally
intensive than the simple search-and-replace functions we examined earlier in this chapter. ”
And finally:
“Therefore, you should use them only when appropriate—that is,
when using the simpler functions is either impossible or so complicated that it’s not worth the effort.”
Then, on http://pl.php.net/manual/en/ref.regex.php we can read:
“Tip
PHP also supports regular expressions using a Perl-compatible syntax using the PCRE functions. Those functions support non-greedy matching, assertions, conditional subpatterns, and a number of other features not supported by the POSIX-extended regular expression syntax.”
and because of this complexity of PCRE the implementations of preg_ functions are much more complicated. That’s why using them should be avoided if not necessary.
That’s my opinion and I would choose ereg
13 June 2008 9:33 AM
hey i m now zend certified!!!
http://www.zend.com/store/education/certification/authenticate.php?ClientCandidateID=ZEND005514&RegistrationID=225719929
13 June 2008 8:30 PM
Congratulations!
4 August 2008 1:08 AM
*In databases that do not support the AUTO_INCREMENT modifier, you must use a LAST_INSERT_ID(id+1) instead to auto-generate a numeric incrementing key.
your answer is probably right, But I can’t figure out how LAST_INSERT_ID is working
if I use that query
insert into member (memid,name,firstname,email)
values(LAST_INSERT_ID()+1,’lname’, ‘fname’, ‘test@test.com’)
LAST_INSERT_ID always return 0+1 unless I set SELECT LAST_INSERT_ID(1),LAST_INSERT_ID(2) and so on before each insert query.
could you explain how do you use it, or if you thing it has a better answer
thank you
10 August 2008 8:40 PM
Which RDBMS are you using? If you refer to mysql, I think better use mysql_insert_id().
20 August 2008 12:15 PM
Hi, in MySQL “LAST_INSERT_ID()” will return the last value of the AUTO_INCREMENT column. But, it can also return an expression: LAST_INSERT_ID(expr) in the case thath you don’t have an auto_increment in the transaction (eg: updates, insert … on duplicate key update).
So, the “+1 solution” would be something like this:
INSERT INTO table VALUES(LAST_INSERT_ID(SELECT MAX(id) + 1 FROM table), val1, val2).
In this case the call to the LAST_INSERT_ID is redundant, you could use the subquery result as the value to the insert:
INSERT INTO table VALUES((SELECT MAX(id) + 1 FROM table), val1, val2).
But, you have the possibility to put an expression in there (eg: a stored function which can return an unique -global- id for example).
I have scheduled the Zend Exam on Friday 29th, of this month!!
Wish me luck!
By the way, GREAT POSTS, very VERY helpful!
21 August 2008 9:51 AM
The question
“*In databases that do not support the AUTO_INCREMENT modifier, you must use a LAST_INSERT_ID(id+1) instead to auto-generate a numeric incrementing key.”
I answered “sequence”. A sequence is a database object which stores a sequence of numbers (much like the auto_increment column), but must be called separatly.
5 October 2008 4:30 AM
Krzysztof Ryba Said,
“That’s my opinion and I would choose ereg”
…and Krzysztof makes a good arguement HOWEVER…
Having taken the practice test twice now (wherein the same question came up on both ocasions) where upon I did answer
“preg_* regular expression functions” and on both occasions I scored “EXCELENT” on the
String Manipulation and Regular Expressions section of the test. That said, seeing as there were so few regex questions on either test, do you think it likely that I got it wrong twice and still scored EXCELLENT both times ????
5 October 2008 2:27 PM
Um. Maybe you are right. But, actually, the purpose of my posts is not to tell which are the correct answers to the exam test. I just want to share some of my information to the users. I will be glad if these have any help for my readers
.
Personally, I think I will choose preg_*.
9 October 2008 1:31 AM
*The method used to create a new node to be added into an XML document using DOM is the ___________ method.
Ambiguous qestion as it fails to specify what kind of node.
e.g. the correct answer COULD be any of …
DomDocument->create_cdata_section
— Creates new cdata node
DomDocument->create_comment
— Creates new comment node
DomDocument->create_element_ns
— Creates new element node with an associated namespace
DomDocument->create_element
— Creates new element node
DomDocument->create_processing_instruction
— Creates new PI node
DomDocument->create_text_node
— Creates new text node
However I AM inclined to agree that
“DomDocument->create_element” is the answer they are looking for.
2 June 2009 6:28 PM
Hello,
”
It’s no so obvious (as many other questions in MockExams, heh).
Page 89-90 of Zend PHP5 Certification Study Guide:
“Perl Compatible Regular Expressions (normally abbreviated as “PCRE”) offer a very
powerful string-matching and replacement mechanism that far surpasses anything
we have examined so far.
”
I agree its not obvious
but the quote above in the study guide is after listing several other (not regular expressions) methods of string comaring/searching methods, and the “these functions are very complex” etc refers to regexp functions in general vs other functions like strstr(), not to perl regexp functions vs posix etc.
so my guess is also preg_*
23 June 2009 8:12 PM
Thank you for good information
hapleng
12 July 2009 6:04 PM
Браво, какие слова…, великолепная мысль
http://www.agata-kristi.info
21 August 2009 10:03 AM
This is a great site! I am taking my certification test tomorrow (Aug 21, 2009) in Boise, ID. This site has been really helpful and I hope to pass with flying colors. I will post any advice after passing/failing my test
22 August 2009 2:20 AM
I passed my cert! Thanks! This site helped a lot!
24 September 2009 8:03 PM
This is a great site! I am taking my certification test day after tomorrow (Sep 26, 2009) in Delhi, India.
This site has been really helpful and I hope to pass with flying colors. I will post any advice after passing/failing my test
26 September 2009 7:21 PM
I passed my cert! Thanks! This site helped a lot!
Thanks Mate
Amit Verma
India
14 February 2010 7:30 PM
[...] readtheweb.info le blog d’un certifié, très intéressant il partage son expérience, ainsi que quelques questions du test Vulcan (ce que je ne fait pas car je me demande si c’est vraiment autorisé…) [...]
28 February 2010 1:41 PM
hi,
what is the right answer for this
* When writing portable database code using PDO, what is the PDO::ATTR_CASE attribute useful for?
from options,
1 – none of above
2 – ensuring all columns are of particular case when fetched
3 – adjust the case of query before it is executed for compatibility reasons
4 – control the switch logic of how quries are processed
5 – allow to adjust the memory cache
my answer is 3rd one.
please suggest its answer, i am appearing in exam on Monday.
thank you
13 March 2010 3:35 PM
Hello, it is the 2nd answer.
27 March 2010 8:42 AM
Thanks for this study guide!!! It was really useful and easy to understand. I just passed the exam this afternoon and I think this guide helped a lot.
5 July 2010 1:36 PM
[...] Zend PHP5 certification Exam study review 10: Supplementary III [...]