Zend PHP5 认证考试研究之11: 附二
In this and the up-coming Post, I listed some extra questions I found during I took the phparch’s Vulcan Zend PHP 5 Certification Testings. This post listed some EASIER but will not be frequently asked in the actual exam I think. But, they are worthy noted here, they can also serve as check points for you previously learned knowledge.
You can determine if you can seek an arbitrary stream in PHP with the stream_get_meta_data() function
The $params['notification'] context variable allows you to define a callback for the stream that will notify your script of certain events during the course of the transaction.
The PDOStatement->nextRowset() method in the PDOStatement class is used to return the next result set in a multi-query statement.
SimpleXML objects can be created from what types of data sources?
File
URL
String
During an HTTP authentication, how does one determine the username and password provided by the browser?
predefined variables PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPE set to the user name, password and authentication type respectively. These predefined variables are found in the $_SERVER and $HTTP_SERVER_VARS arrays.
$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']
End a script in PHP5:
__halt_compiler() ;
die();
exit();
When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used?
===
When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized?
serialize — Generates a storable representation of a value.
When serializing objects, PHP will attempt to call the member function __sleep() prior to serialization. This is to allow the object to do any last minute clean-up, etc. prior to being serialized. Likewise, when the object is restored using unserialize() the __wakeup() member function is called.
Which of the following are examples of the new engine executor models available in PHP 5?
Three execution models (CALL, GOTO, SWITCH) that the new virtual machine of PHP 5.1
Switch
Conditional
Goto
Call
Dynamic
The array_sum() function is used to add up the values of every entry within an array.
The children() method can be used from a SimpleXML node to return an iterator containing a list of all of the current node’s sub nodes.
To destroy one variable within a PHP session you should use which method in PHP 5?
session_destroy(); session_regenerate_id();
Unlike a database such as MySQL, SQLite columns are not explicitly typed. Instead, SQLite catagorizes data into which of the following catagories?
Textual and Numeric
Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?
Iterator
ArrayAccess
The stream_set_timeout() function is used to modify the amount of time PHP will wait for a stream before timing out during reading or writing.
In a general sense, which is more important: performance or maintainability of an application?
maintainability first, performance second.
When using a function such as strip_tags, are markup-based attacks still possible?
yes.
string strip_tags ( string $str [, string $allowable_tags ] )
Which of the following are valid PHP variables?
@$foo
// &$variable
${0×0}
$variable
// $0×0
Unlike the old MySQL extension, the new MySQLi extension requires that you provide what when performing a query when using the procedural interface?
Procedural style:
mixed mysqli_query ( mysqli $link , string $query [, int $resultmode ] )
A FOREIGN key is particularly useful for maintaining data integrity within your database, and has the potential to ease the complexity of your PHP scripts by allowing the database to manage cascading deletes of data.
If you would like to store your session in the database, you would do which of the following?
Create functions for each session handling step and use session_set_save_handler() to override PHP’s internal settings
One can determine if it is possible to send HTTP headers from within your PHP script using which of the following functions?
bool headers_sent ([ string &$file [, int &$line ]] )
Check to make sure we haven’t already sent
the header:
!in_array(”Location: $url”, headers_list())
The tempnam function is used to generate a file resource in the file system with a randomly-generated filename to be used as temporary storage
string tempnam ( string $dir , string $prefix )
Creates a file with a unique filename, with access permission set to 0600, in the specified directory. If the directory does not exist, tempnam() may generate a file in the system’s temporary directory, and return the name of that.
感谢您阅读本文章。您现在可以 Read Comments (6)
日志信息
本日志发布于 1月 24, 2008 8:40 下午 发布在 php 标记为:技术,网站开发,Zend认证,php你可以跟进任何对此文章的回复通过 Comments Feed. 你可以 留一个评论 ,或 一个 Trackback .
前一日志 Zend PHP5 认证考试研究之10: 附一 »
下一日志 Zend PHP5 认证考试研究之12: 附三 »
- Review, php|architect’s Guide to Programming with Zend Framework
- Use Writer, the online Darkroom version!
- Learn to Design Web Themes and Templates with New Wiki
- 国谷哥发布: 四川震区急需 260 万顶帐篷
- WordPress problem: Url encoding on Tag’s slug.
- Curl better than simplexml_load_file when web screen scrapping
- How to use SimpleXML parsing XML data with namespace and CDATA
- 关于生活的哲学
- Zend PHP5 认证考试研究之12: 附三
- Zend PHP5 认证考试研究之11: 附二
english












10月 5, 2008 12:24 上午
When checking to see if two variables contain the same instance of an object, which of the following comparisons should be used?
if($obj1 === $obj2) // ??? are you sure it’s not…
if($obj1 instanceof $obj2) // ???
e.g. (from the manual)…
“Although instanceof is usually used with a literal classname, it can also be used with another object or a string variable:”
if($a instanceof $b) echo “foo”;
if($a === $b) echo “bar”;
//returns foo
10月 5, 2008 2:30 下午
Yeah, from the manual, it says instanceof can also used with another object or a string variable. However, look at the example#5 on php.net, the use of another object example is:
$a = new MyClass;
$b =new MyClass;
if($a instanceof $b)…
Here, $a and $b are not the same instance of an object, they are two different instance of the same class, eventhough the if statement will return true.
10月 6, 2008 11:17 下午
Here, $a and $b are not the same instance of an object, they are two different instance of the same class, eventhough the if statement will return true…
Ok, I see your point there, but without simply stating that $a=$b; can you provide a simple example wherein $a and $b would in fact be “the same instance of an object” never mind where $a and $b “contain” the same instance? I confess that I am having some difficulty imagining such a scenario in the real world.
10月 7, 2008 4:18 下午
Hi!
On question
“To destroy one variable within a PHP session you should use which method in PHP 5?”
you answered
session_destroy(); session_regenerate_id();
Why? To destroy ONE variable you should use unset() method, like unset ($_SESSION['var'])
P.S. Thank you for interesting article
10月 7, 2008 9:32 下午
Hi Alexey, you are right. My answers were wrong, it should use unset. Actually, I knew they are wrong a long time ago; I forgot to correct it. And, later, I thought, maybe just keep it as is. I never said that all these here are the “correct answers” :). Thank you very much for your this comments!
10月 7, 2008 9:39 下午
tjmcd1963, I knew what you mean. I think, maybe in the case that you want to test if a class is a singleton? E.g.:
$a = new ForeignClass();
$b = new ForeignClass();
if($a === $b) {echo “It is a singleton.”;} else{echo “It is not a singleton.”;}
Of coures, in the real world, this is a very rare scenario, even you got a class from somewhere, and it was not documented and has no comment, you can always check the source code of the Class right? But I also can’t think another example in the real world right now. But, this is may useful in large project, and you use $a=$b; but after pass $a and $b around, in some places, you forgot you used this stating or it is just another person on the project, so use if($a===$b).
P.S., I think “the same instance of an object” is actually “the same instance of an class”. The question itself seem has a problem.