Вы находитесь на странице: 1из 6

PHP QUIZ

1. Which of these could be used to maintain a variable from one form to the next? a. variable_issaved() b. $_SESSION c. static() d. An image watermark 2. To get the age of a dog held in the object $ourdog, you might write: a. b. c. d. $ dogage = $ourdog->getage(); $ dogage = $ourdog.getage(); $dogage = getage($ourdog); $dogage = getage.$ourdog();

3. The -q option on the PHP command line used to mean a. b. c. d. Run from the command line rather than from a web page Don't echo back any user inputs Don't output any HTML headers automatically Don't actually run PHP - just give a usage line and list of options

4. What's the difference between requrie() and require_once()? a. require_once() raises a FATAL ERROR while require() raises a WARNING when the required page is not found. b. multiple calls to require() with the same file name would include the same page multiple times while multiple calls to require_once() with the same file name would only include the file once. c. there is no difference. require_once() has been deprecated in PHP 5.0 d. require() can be used to include remote files while require_once() is limited to local files.

5. Consider the following PHP code... <?php interface Coffee { public function getPrice(); } class Americano implements Coffee { private $cost = 2.50; public function getPrice() { return $this->cost; } } class withExtraShotOfEspresso implements Coffee { private $cost = 0.50; private $coffee; public function __construct(Coffee $coffee) { $this->coffee = $coffee; } public function getPrice() { return $this->cost + $this->coffee->getPrice(); } } ?> Imagine you wanted an Americano with two extra shots of Espresso. Can you write a couple of lines of code that would generate that drink from the classes above, and print out the total cost of the drink? Answer:

6. In the example above, 'withExtraShotOfEspresso' is an example of which OO design pattern? a. Singleton b. Strategy c. Decorator d. Command

7. What does Views (Drupal) do and how do you use it (in two words)?

8. What are the necessary files for creating a new module (in case that module name is mytest)?

a. mytest.php, mytest.ini b. mytest.module, mytest.ini c. mytest.module mytest.info d. mytest.inc mytest.ini

9. What is Drupal internal logging module? a. There is no logging module in Drupal b. Zend_Logger c. Watchdog d. Logger 10. Consider a Drupal hook named foo_bar() a. foo is the name of the module and bar is the name of the hook b. foo is the name of the function and bar is the name of the hook c. foo is the name of the theme and bar is the name of the action d. This is not the correct format for drupal hooks naming. 11. How can a page be redirected in Drupal to a different Drupal page? a. drupal_goto()

b. drupal_redirect() c. Header(Location: http://www.example.com) d. Only by javascript 12. Difference between hook_init and hook_boot a. hook_init & hook_boot have same functionality b. hook_boot called after drupal page rendered & hook_init before c. hook_init create template variables & hook_boot place them on the page d. hook_boot is called before modules loaded into memory & hook_init called after all modules are loaded into memory.

13. Which hook to use to add your own element to form created by another module a. hook_elements() b. hook_form() c. hook_forms() d. hook_form_alter() 14. How to make sure hook_init() of your module will be processed before hook_init() of module2 a. Install it before module2 b. Give your module name that is "less" than name of module2 in alphabetic order c. Set weight of your module less then weight of module2 in table "system" d. Use hook_module_seetings() to give Drupal weight of your module 15. In jQuery, how can one refer to the following <div id=div1>? a. $(div.div1)

b. $(#div1) c. $(div1) d. $(page.div1) 16. Consider the following code: <div class=first> <div class=second third> <span id=span1>1</span> <span id=span2>2</span> </div> <div class=second> <div class=third> <span id=span3>3</span> <span id=span4>4</span> </div> What does jQuery returns while referring to $(.first .second.third > *)? a. <div class=second third><span id=span1>1</span><span id=span2>2</span></div> b. <span id=span3>3</span><span id=span4>4</span> c. <div class=second><div class=third><span id=span1>4</span><span id=span2>4</span></div></div> d. <span id=span1>1</span><span id=span2>2</span>
17. What is the correct way to write a JavaScript array? a. b. c. d.

var txt = new Array="a","b","c" var txt = new Array("a","b","c") var txt = new Array(1:"a",2:"b",3:"c") var txt = new Array:1=("a")2=("b")3=("c")

18. What will be the result of the next script? function f () {alert (f + "; f ()")}; f (); a. Infinity loop b. Popup message with the text of the script c. Script can`t be executed because of an error d. f

19. How do you add a background color for all <h1> elements?
a. b. c. d.

h1.all {background-color:#FFFFFF} all.h1 {background-color:#FFFFFF} h1 {background-color:#FFFFFF} .h1{background-color:#FFFFFF}

20. How to move span element with ID "span1" to the end of second paragraph: <div class="container"> <p id="p1">Hello, <span id="span1">movable span</span></p> <p id="p2">You should be placed after me: </p> </div> a. $('#span1').appendTo('#p2'); b. $('#span1').insertAfter('#p2'); c. $('<span id="span1">movable span</span>').appendTo("#p2"); $('#span1').empty(); d. $('#span1').remove();$('<span id="span1">movable span</span>').appendTo("#p2");