1. Question: Which of the following expressions multiply the value of the integer variable $a by 4? (Choose 2)

    A
    $a *= pow (2, 2);

    B
    $a >>= 2;

    C
    $a <<= 2;

    D
    $a += $a + $a;

    E
    None

    Note: The correct answers are A and C. In Answer A, the pow function is used to calculate 22, which corresponds to 4. In Answer C, the left bitwise shift operator is used to shift the value of $a by two bits to the left, which corresponds to a multiplication by 4.
    1. Report
  2. Question: How can a script come to a clean termination?

    A
    When exit() is called

    B
    When the execution reaches the end of the current file

    C
    When PHP crashes

    D
    When Apache terminates because of a system problem

    E
    When close() is called

    Note: The only answer that really fits the bill is A. A script doesn’t necessarily terminate when it reaches the end of any file other than the main one—so the “current” file could be externally included and not cause the script to terminate at its end. As far as PHP and Apache crashes, they can hardly be considered “clean” ways to terminate a script.
    1. Report
  3. Question: How are session variables accessed?

    A
    Through $_GET

    B
    Through $_POS

    C
    Through $_REQUEST

    D
    Through global variables

    E
    None

    Note: Although session data can be accessed using the global variables if the register_globals INI setting is turned on, the exam uses a version of PHP configured using the default php.ini file found in the official PHP distribution. In recent versions of PHP, the register_globals setting is turned off by default because of its serious security implications. As a result, Answer E is correct.
    1. Report
  4. Question: What function causes the following header to be added to your server’s output?
    Set-Cookie: foo=bar;
    Your Answer: ______

    A
    header()

    B
    setcookie()

    C
    setrawcookie()

    D
    all

    E
    none

    Note: Clearly, this question refers to the setcookie or setrawcookie functions, although the header function could be used as well.
    1. Report
  5. Question: Under normal circumstances—and ignoring any browser bugs—how can a cookie be accessed from a domain other than the one it was set for?

    A
    By consulting the HTTP_REMOTE_COOKIE header

    B
    It cannot be done

    C
    By setting a different domain when calling setcookie()

    D
    By sending an additional request to the browser

    E
    By using Javascript to send the cookie as part of the URL

    Note: Answer B is correct. Browsers simply do not allow an HTTP transaction that takes place on one domain to set cookies for another domain. Doing otherwise would present clear security implications: for example, a malicious page on one domain could overwrite your session ID for another domain and force you to use another session to which a third party has access without your knowledge.
    1. Report
  6. Question: How can the index.php script access the email form element of the following HTML form? (Choose 2)
    <form action="index.php" method="post">
      <input type="text" name="email"/>
    </form>

    A
    $_GET['email']

    B
    $_POST['email']

    C
    $_SESSION['text’]

    D
    $_REQUEST['email']

    E
    $_POST['text']

    Note: Since the form’s method is post, the script will only be able to read the value through the $_POST and $_REQUEST superglobal arrays. The element’s name (email) is used as the key for the value in the array and, therefore, Answers B and D are correct. Note that, although perfectly valid from a logical perspective, the use of $_REQUEST should be discouraged because of potential security implications.
    1. Report
  7. Question: What will be the net effect of running the following script on the $s string? (Choose 2)
    <?php
      $s = '<p>Hello</p>';
      $ss = htmlentities ($s);
      echo $s;
    ?>

    A
    The string will become longer because the angular brackets will be converted to their HTML meta character equivalents

    B
    The string will remain unchanged

    C
    If the string is printed to a browser, the angular brackets will be visible

    D
    If the string is printed to a browser, the angular brackets will not be visible and it will be interpreted as HTML

    E
    The string is destroyed by the call to htmlentities()

    Note: This question tests nothing about your knowledge of HTML encoding—and everything about your ability to properly interpret code. The $s function is left unaltered by the call to htmlentities(), which returns the modified string so that it can be assigned to $ss. Therefore, Answers B and D are correct. If you’re wondering whether this is an unfair “trick” question, do keep in mind that, often, the ability to find and resolve bugs revolves around discovering little mistakes like this one.
    1. Report
  8. Question: If no expiration time is explicitly set for a cookie, what happens to it?

    A
    It expires right away

    B
    It never expires

    C
    It is not set

    D
    It expires at the end of the user’s browser session

    E
    It expires only if the script doesn’t create a server-side session

    Note: Cookies automatically expire at the end of the user’s browser session if no explicit expiration time is set. Cookies are not necessary to maintain a server-side session, so answer D is correct.
    1. Report
  9. Question: Consider the following form and subsequent script. What will the script print out if the user types the word “php” and “great” in the two text boxes respectively?
    <form action="index.php" method="post">
      <input type="text" name="element[]">
      <input type="text" name="element[]">
    </form>
    <?php
      echo $_GET['element'];
    ?>

    A
    Nothing

    B
    Array

    C
    A notice

    D
    phpgreat

    E
    greatphp

    Note: Since the form is submitted using a POST HTML transaction, whatever values are typed in the text boxes are only going to be available in the $_POST superglobal array. Therefore, Answer C is correct, since the $_GET array won’t contain any values and PHP will issue a notice to this effect.
    1. Report
  10. Question: In an HTTPS transaction, how are URLs and query strings passed from the browser to the web server?

    A
    They are passed in clear text, and the subsequent transaction is encrypted

    B
    They are encrypted

    C
    The URL is left in clear text, while the query string is encrypted

    D
    The URL is encrypted, while the query string is passed in clear text

    E
    To ensure its encryption, the query string is converted into a header and passed along with the POST information

    Note: When an HTTPS transaction takes place, the browser and the server immediately negotiate an encryption mechanism so that any subsequent data is not passed in clear text—including the URL and query string, which are otherwise passed the same way as with a traditional HTTP transaction. Answer B is, therefore, correct.
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd