Friday, April 4, 2008

Php Questions

Object-oriented questions

  1. Class definitions must end with a semi-colon: true or false?

    True
    False


  2. Calling __clone() is not allowed: true or false?

    True
    False


  3. Abstract classes cannot be instantiated: true or false?

    True
    False


  4. You can use objects as an array in foreach loops: true or false?

    True
    False


  5. Private variables can only be accessed from within the class that defined them, or any subclass of it: true or false?

    True
    False


Function questions

  1. What function would you use to tell the browser the content type of the data being output?

    imagejpeg()
    imageoutput()
    flush()
    header()
    imageload()


  2. What parameters does the func_get_args() function take?

    0: It doesn't take any parameters
    1: name of function to check
    2: name of function to check, boolean "count optional arguments"


  3. What does the array_shift() function do?

    Add an element to an array
    Removes an element from an array
    Shifts all elements towards the back of the array
    Switches array keys and values
    Clears the array


  4. What function would you use to delete a file?

    unlink()
    delete()
    fdelete()
    file_delete()


  5. What is the difference between exec() and pcntl_exec()?

    Nothing, they are the same
    pcntl_exec() forks a new process
    pcntl_exec() can only be called from a child process
    None of the above


  6. If $string is "Hello, world!", how long would the output of sha1($string) be?

    It varies
    16 characters
    20 characters
    24 characters
    32 characters
    40 characters


  7. If the input of chr() is $a and the output is $b, what function would take input $b and produce output $a?

    chr()
    rch()
    ord()
    strrev()
    chr(chr())
    chrrev()


  8. If $a is "Hello, world!", is this statement true or false: md5($a) === md5($a)

    True
    False


  9. Which function returns true when magic quotes are turned on?

    get_magic_quotes()
    magic_quotes_get()
    magic_quotes()
    get_magic_quotes_gpc()
    get_quotes()


  10. The functions get_required_files() and get_included_files() are identical, true or false?

    True
    False


  11. If $arr was an array of ten string elements with specific keys, what would array_values(ksort($arr)) do?

    Create a new array of just the values, then sort by the keys
    Create a new array of just the values, then ignore the sort as there are no keys
    Sort the array by key, then return a new array with just the values
    Trigger a warning
    None of the above


  12. What is the return value of array_unique()?

    Boolean
    Integer
    Array
    It varies
    None of the above


Miscellaneous questions

  1. Output buffering compression is...

    High on CPU resources, low on network resources
    Low on CPU resources, high on network resources
    High on CPU resources, high on network resources
    Low on CPU resources, low on network resources


  2. You can exit a PHP code block (that is, use ?> to go back to HTML mode) while in the middle of a class definition: true or false?

    True
    False


  3. Examine this code - on which line is there an error?


    <?php
    class dog {
    public function bark() {
    echo "Woof!";
    }
    };

    $foo = new dog;
    $foo->bark();
    ?>



    Line 2 (class dog)
    Line 3 (public function bark())
    Line 4 (echo "Woof!")
    Line 6 ( }; )
    Line 8 ($foo = new dog)
    Line 9 ($foo->bark())
    There is no error


  4. True or false: to ensure maximum portability for your scripts, you should try to use exceptions.

    True
    False


  5. What directive would you change in your php.ini file to disable assert()?

    assert
    assert.active
    assert.enable
    assert.assert
    assert.options
    None of the above


  6. Which of these statements is true?

    PHP 4 had object orientation, but not extensions
    PHP 4 had extensions, but not object orientation
    PHP 4 had object orientation, but not exceptions
    PHP 4 had exceptions, but not object orientation
    None of the above

Mathematical questions

  1. "10" == 10: true or false?

    True
    False


  2. "10" === 10: true or false?

    True
    False


  3. "10" !== 10: true or false?

    True
    False


  4. 10 === 010: true or false?

    True
    False


  5. 010 >= 10: true or false?

    True
    False


  6. What is the value of this sum: 5 * 6 / 2 + 2 * 3

    0
    3
    4
    19
    21
    24
    29
    51


Database questions

  1. This SQL statement is valid "SELECT ID, Name FROM some_table ORDER BY Name WHERE ID < 100" - true or false?

    True
    False


  2. Joins are fastest when done using which data type:

    INT
    JOIN
    FLOAT
    INDEX
    CHAR
    VARCHAR
    CACHE
    None of the above


  3. SQLite is compiled into PHP 5 by default: true or false?

    True
    False


  4. All five parameters to mysql_connect() are optional, true or false?

    True
    False


  5. What is the best description of a normalised table?

    One where optimal data types are used
    One where data is not repeated
    One where the schema is valid
    One that is properly indexed
    One that has been defragmented


String questions

  1. If $string is set to "Hello, world!", what is $string{4}?

    H
    e
    l
    o
    w
    r
    d


  2. What is the case-insensitive version of the strcmp() function?

    strcmpi()
    stricmp()
    strcasecmp()
    istrcmp()


  3. How many parameters can the trim() function take?

    0
    1
    2
    3
    4+


  4. The parse_str() function...

    Checks a string of PHP code is valid
    Checks a string of PHP code is valid, then executes it
    Searches a string for non-English characters
    Converts the contents of a string into variables


  5. What will this function return: preg_match("[A-Za-z0-9_]*", "This_is_a_test")

    True
    False


  6. What would implode(".", explode(",", $string)) do?

    Replace all full stops (periods) with spaces
    Replace all full stops with commas
    Delete all full stops
    None of the above

No comments:

Post a Comment