1. Question: What is the best way to ensure that a user-defined function is always passed an object as its single parameter?

    A
    function myfunction(stdClass $a)

    B
    function myfunciton($a = stdClass)

    C
    Use is_object() within the function

    D
    There is no way to ensure the parameter will be an object

    E
    function myfunction(Object $a)

    Note: Not available
    1. Report
  2. Question: What does the following function do, when passed two integer values for $p and $q?
    <?php
    function magic($p, $q) {
      return ($q == 0) ? $p : magic($q, $p % $q);
    }
    ?>

    A
    Loops infinitely

    B
    Switches the values of $p and $q

    C
    Determines if they are both even or odd

    D
    Determines the greatest common divisor between them

    E
    Calculates the modulus between the two

    Note: Not available
    1. Report
  3. Question: What would go in place of ?????? below to make this script execute without a fatal error?
    <?php
    
    $a = 1;
    $b = 0;
    
    ??????
    
    $c = $a / $b;
    ?>

    A
    quit();

    B
    die();

    C
    stop();

    D
    __halt_compiler();

    E
    exit();

    Note: Not available
    1. Report
  4. Question: What is the output of the following?
    <?php
    
    $a = 20;
    
    function myfunction($b) {
    	$a = 30;
    	
    	global $a, $c;
    	return $c = ($b + $a);
    }
    
    print myfunction(40) + $c;
    
    ?>

    A
    120

    B
    Syntax Error

    C
    60

    D
    70

    E
    20

    Note: Not available
    1. Report
  5. Question: What would you replace ??????? with, below, to make the string Hello, World! be displayed?
    <?php
    
    function myfunction() {
            ???????
    	print $string;
    }
    
    myfunction("Hello, World!");
    
    ?>

    A
    There is no way to do this

    B
    $string = $argv[1];

    C
    $string = $_ARGV[0];

    D
    list($string) = func_get_args();

    E
    $string = get_function_args()

    Note: Not available
    1. Report
  6. Question: What is the output of the following function?
    <?php
    
    function &find_variable(&$one, &$two, &$three) {
    	
    	if($one > 10 && $one < 20) return $one;
    	if($two > 10 && $two < 20) return $two;
    	if($three > 10 && $three < 20) return $three;
    }
    
    $one = 2;
    $two = 20;
    $three = 15;
    
    $var = &find_variable($one, $two, $three);
    
    $var++;
    
    print "1: $one, 2: $two, 3: $three";
    
    ?>

    A
    1: 2, 2: 20, 3: 15

    B
    1: 3, 2:21, 3:16

    C
    1: 2, 2:21, 3:15

    D
    1: 3, 2: 20, 3: 15

    E
    1: 2, 2: 20, 3: 16

    Note: Not available
    1. Report
  7. Question: For an arbitrary string $mystring, which of the following checks will correctly determine if the string PHP exists within it?

    A
    if(strpos($mystring, "PHP") !== false)

    B
    if(!strpos($mystring,"PHP"))

    C
    if(strpos($mystring, "PHP") === true)

    D
    if(strloc($mystring, "PHP") == true)

    E
    if(strloc($mystring, "PHP") === false)

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd