PHP


Advance PHP Questions With Answers (Odesk & Elance)

?>
a.    1 (Answer)
b.    Syntax error
c.    0

Question:
What does the array_combine (a, b) function do?
a.    It appends b to a
b.    It associates all keys of a with the values of b and returns a new array
c.    It returns a new array with all values of b added to the values of a
d.    It doesn’t exist
e.    None of the above   (Answer)
Question:
What will be the output of the following code?
$a = “print”;
$a (“hello”);
?>
a.    print
b.    hello
c.    print hello
d.    fatal error   (Answer)
e.    None of the above
Question:
What is the precedence between && and “and”?
a.    && is higher than “and”   (Answer)
b.    “and” is higher than &&
c.    They have the same precedence
d.    Those operators don’t exist
Question:
What will be the output of the following code?
echo false;
?>
a.    0
b.    false
c.    FALSE
d.    Nothing (Answer)
e.    Syntax error
Question:
Which of the following is the operator with the highest precedence?
a.    +
b.    instanceof
c.    new (Answer)
d.    =
e.    None of the above
Question:
What is “?:”  ?
a.    A logical operator
b.    A comparison operator
c.    A ternary operator  (Answer)
d.    A bitwise operator
e.    None of the above
Question:
What is the string concatenation operator in PHP?
a.    +
b.    ||
c.    . (dot)  (Answer)
d.    |||
e.    None of the above
Question:
Is the PHP float type guaranteed to be 64 bit IEEE?
a.    yes (Answer)
b.    no
Question:
Which of the following is the operator with the lowest precedence?
a.    new
b.    and
c.    , (comma) (Answer)
d.    =
Question:
Which statement will return true?
a.    is_numeric (“200″)  (Answer)
b.    is_numeric (“20,0″)
c.    is_numeric (“$200″)
d.    is_numeric (“.25e4″)  (Answer)
e.    None
Question:
What will be the output of the following code?
print null == NULL;
?>
a.    1 (Answer)
b.    0
Question:
What is the output of the following code?
echo 0×500;
?>
a.    500
b.    0×500
c.    0500
d.    1280  (Answer)
e.    320
Question:
When comparing two arrays, what is the difference between == and === ?
a.    == compares keys while === compares keys and values
b.    === also compares the order and types of the objects
c.    === compares the array references
d.    They are identical   (Answer)
e.    None of the above
Question:
What is the initial value of a variable?
a.    0
b.    “0″
c.    NULL  (Answer)
d.    Any value
Question:
What will be the output of the following code?
$a = 3;
print ‘$a’;
?>
a.    3
b.    $a   (Answer)
c.    Syntax error
d.    None of the above
Question:
With the following code, will the word Hello be printed?
//?>Hello
a.    yes  (Answer)
b.    no
Question:
What will be the output of the following code?
$s = “Hello world!”;
print $s[4];
?>
a.    H
b.    e
c.    l
d.    o  (Answer)
e.    ” ” (a space)
Question:
What is the output of the following code?
$a = (1 << 0);
$b = (1 << 1);
echo $b | $a;
?>
a.    0
b.    1
c.    2
d.    3  (Answer)
e.    8
f.    32
g.    Syntax error
Question:
What will be the output of the following code?
echo “5.0″ == “5″;
?>
a.    0
b.    1  (Answer)
c.    5.0
d.    Syntax error
e.    None of the above
Question:
What function should you use to join array elements with a glue string?
a.    join_str
b.    implode (Answer)
c.    connect
d.    make_array
e.    None of the above
Question:
What is the output of the following code?
echo (2) . (3 * (print 3));
?>
a.    233
b.    29
c.    329
d.    323  (Answer)
e.    Syntax error
Question:
How can you check if a function exists?
a.    With function_exists function  (Answer)
b.    With has_function function
c.    With $a = “function to check”; if ($a ()) // then function exists
d.    It can’t be done
e.    None of the above
Question:
What is the output of the following code?
$a = 0;
echo ~$a;
?>
a.    -1  (Answer)
b.    0
c.    1
d.    10
e.    Syntax error
Question:
What is the associativity of +=?
a.    left
b.    right
c.    it is non-associative  (Answer)
Question:
With what encoding does chr () work?
a.    ASCII
b.    UTF-8   (Answer)
c.    UTF-16
d.    Implementation dependent
e.    None of the above
Question:
Will the trim function strip NULL bytes?
a.    Yes
b.    No   (Answer)
Question:
Which of the following is a type of array in PHP?
a.    string
b.    compound
c.    callback
d.    scalar
e.    struct  (Answer)
Question:
What will be the output of the following code?
$a = 0×01;
$b = 0×02;
echo $a === $b >> $a;
?>
a.    0
b.    1  (Answer)
c.    Syntax error
Question:
Can feof () be used with a file opened by fsockopen () ?
a.    yes
b.    no  (Answer)
Question:
Knowing that the output of the first echo is “2.5″, what will be the output of the third one?
setlocale(LC_ALL, “fr_FR”);
echo (string)2.5;
echo “\n”;
echo (float)(string)2.5;
?>
a.    2.5 (Answer)
b.    25
c.    2,5
d.    2
e.    Syntax error
Question:
What function will you use to remove the first element of an array?
a.    array_remove_first_element
b.    array_shift    (Answer)
c.    array_ltrim
d.    a[0] = nil
e.    None of the above
Question:
What will be the output of the following code?
$a = “Hello”;
if (md5($a) === md5($a))
print “True”;
else
print “False”;
?>
a.    True  (Answer)
b.    False
Question:
What does the array_unshift () function do?
a.    It shifts an element off the beginning of array
b.    It shifts all bits of the array to the left
c.    It undo what array_shift does
d.    None of the above   (Answer)
Question:
Should assert () be used to check user input?
a.    yes  (Answer)
b.    no
Question:
In the following list, which one is not a string literal definition?
a.    single quoted
b.    heredoc syntax
c.    nowdoc syntax
d.    double quoted
e.    All are string literals  (Answer)
Question:
What will be the output of the following code?
$a = “NULL”;
echo !empty ($a);
?>
a.    0
b.    1  (Answer)
c.    TRUE
d.    FALSE
e.    NULL
Question:
What will be the output of the following code?
$foo = 5 + “10 things”;
print $foo;
?>
a.    510 things
b.    5 10 things
c.    15 things
d.    15   (Answer)
e.    None of the above
Question:
What will be the output of the following code?
$a = (1 << 0);
$b = (1 << $a);
$c = (1 << $b);
echo ($c || $b) << 2 * $a | $a;
?>
a.    1
b.    3
c.    5  (Answer)
d.    12
e.    27
f.    32
g.    Syntax error
Question:
Which fopen option opens the file for reading and writing; placing the file pointer at the beginning of the file without truncating it.
a.    r
b.    r+
c.    w
d.    W+
e.    a
Question:
What is the output of the following code?
echo  0500;
?>
a.    100
b.    500
c.    0500
d.    320
e.    None of the above  (Answer)
Question:
What is the size limit of strings in php?
a.    1024bytes
b.    100Mbytes
c.    256Kbytes
d.    There is no limit (hardware limit)   (Answer)
e.    None of the above
Question:
What kind of regular expression does PHP include?
a.    PCRE
b.    Java REGEX
c.    Ruby REGEX
d.    None of the above  (Answer)
Question:
What is the output of the following code?
echo ’1′.print(2) + 3;
a.    123
b.    321
c.    511  (Answer)
d.    155
e.    432
Question:
Is the following code valid?
$a = 5;
if ($a == 5):
echo “Hello”;
echo “1″;
else:
echo “Not hello”;
echo “2″;
endif;
?>
a.    yes  (Answer)
b.    no
Question:
Can PHP use Gettext?
a.    yes  (Answer)
b.    no
Question:
What will be the output of the following code on a machine using IEEE 754 floats?
print (19.6*100) !== (double)1960;
?>
a.    0
b.    1  (Answer)
c.    Nothing
d.    Syntax error
Question:
What will be the output of the following code?
$a = 3;
print ‘$a’;
?>
a.    3
b.    $a  (Answer)
c.    Syntax error
d.    None of the above
Question:
What will be the output of the the following code?
echo !!!0;
?>
a.(Answer)
b.Syntax error
c.0
 Question:
What does the array_combine (a, b) function do?
a.It appends b to a
b.It associates all keys of a with the values of b and returns a new array
c.It returns a new array with all values of b added to the values of a
d.It doesn’t exist
e.None of the above   (Answer)
 Question:
What will be the output of the following code?
$a = “print”;
$a (“hello”);
?>
a.print
b.hello
c.print hello
d.fatal error   (Answer)
e.None of the above
 Question:
What is the precedence between && and “and”?
a.&& is higher than “and”   (Answer)
b.“and” is higher than &&
c.They have the same precedence
d.Those operators don’t exist
 Question:
What will be the output of the following code?
echo false;
?>
a.0
b.false
c.FALSE
d.Nothing (Answer)
e.Syntax error
 Question:
Which of the following is the operator with the highest precedence?
a.+
b.instanceof
c.new (Answer)
d.=
e.None of the above
 Question:
What is “?:”  ?
a.A logical operator
b.A comparison operator
c.A ternary operator  (Answer)
d.A bitwise operator
e.None of the above
 Question:
What is the string concatenation operator in PHP?
a.+
b.||
c.. (dot)  (Answer)
d.|||
e.None of the above
 Question:
Is the PHP float type guaranteed to be 64 bit IEEE?
a.yes (Answer)
b.no
 Question:
Which of the following is the operator with the lowest precedence?
a.new
b.and
c., (comma) (Answer)
d.=
 Question:
Which statement will return true?
a.is_numeric (“200″)  (Answer)
b.is_numeric (“20,0″)
c.is_numeric (“$200″)
d.is_numeric (“.25e4″)  (Answer)
e.None
 Question:
What will be the output of the following code?
print null == NULL;
?>
a.1 (Answer)
b.0
 Question:
What is the output of the following code?
echo 0×500;
?>
a.500
b.0×500
c.0500
d.1280  (Answer)
e.320
 Question:
When comparing two arrays, what is the difference between == and === ?
a.== compares keys while === compares keys and values
b.=== also compares the order and types of the objects
c.=== compares the array references
d.They are identical   (Answer)
e.None of the above
 Question:
What is the initial value of a variable?
a.0
b.“0″
c.NULL  (Answer)
d.Any value
 Question:
What will be the output of the following code?
$a = 3;
print ‘$a’;
?>
a.3
b.$a   (Answer)
c.Syntax error
d.None of the above
 Question:
With the following code, will the word Hello be printed?
//?>Hello
a.yes  (Answer)
b.no
 Question:
What will be the output of the following code?
$s = “Hello world!”;
print $s[4];
?>
a.H
b.e
c.l
d.o  (Answer)
e.” ” (a space)
 Question:
What is the output of the following code?
$a = (1 << 0);
$b = (1 << 1);
echo $b | $a;
?>
a.0
b.1
c.2
d.3  (Answer)
e.8
f.32
g.Syntax error
 Question:
What will be the output of the following code?
echo “5.0″ == “5″;
?>
a.0
b.1  (Answer)
c.5.0
d.Syntax error
e.None of the above
 Question:
What function should you use to join array elements with a glue string?
a.join_str
b.implode (Answer)
c.connect
d.make_array
e.None of the above
 Question:
What is the output of the following code?
echo (2) . (3 * (print 3));
?>
a.233
b.29
c.329
d.323  (Answer)
e.Syntax error
 Question:
How can you check if a function exists?
a.With function_exists function  (Answer)
b.With has_function function
c.With $a = “function to check”; if ($a ()) // then function exists
d.It can’t be done
e.None of the above
 Question:
What is the output of the following code?
$a = 0;
echo ~$a;
?>
a.-1  (Answer)
b.0
c.1
d.10
e.Syntax error
 Question:
What is the associativity of +=?
a.left
b.right
c.it is non-associative  (Answer)
 Question:
With what encoding does chr () work?
a.ASCII
b.UTF-8   (Answer)
c.UTF-16
d.Implementation dependent
e.None of the above
 Question:
Will the trim function strip NULL bytes?
a.Yes
b.No   (Answer)
 Question:
Which of the following is a type of array in PHP?
a.string
b.compound
c.callback
d.scalar
e.struct  (Answer)
 Question:
What will be the output of the following code?
$a = 0×01;
$b = 0×02;
echo $a === $b >> $a;
?>
a.0
b.1  (Answer)
c.Syntax error
 Question:
Can feof () be used with a file opened by fsockopen () ?
a.yes
b.no  (Answer)
 Question:
Knowing that the output of the first echo is “2.5″, what will be the output of the third one?
setlocale(LC_ALL, “fr_FR”);
echo (string)2.5;
echo “\n”;
echo (float)(string)2.5;
?>
a.2.5 (Answer)
b.25
c.2,5
d.2
e.Syntax error
 Question:
What function will you use to remove the first element of an array?
a.array_remove_first_element
b.array_shift    (Answer)
c.array_ltrim
d.a[0] = nil
e.None of the above
 Question:
What will be the output of the following code?
$a = “Hello”;
if (md5($a) === md5($a))
print “True”;
else
print “False”;
?>
a.True  (Answer)
b.False
 Question:
What does the array_unshift () function do?
a.It shifts an element off the beginning of array
b.It shifts all bits of the array to the left
c.It undo what array_shift does
d.None of the above   (Answer)
 Question:
Should assert () be used to check user input?
a.yes  (Answer)
b.no
 Question:
In the following list, which one is not a string literal definition?
a.single quoted
b.heredoc syntax
c.nowdoc syntax
d.double quoted
e.All are string literals  (Answer)
 Question:
What will be the output of the following code?
$a = “NULL”;
echo !empty ($a);
?>
a.0
b.1  (Answer)
c.TRUE
d.FALSE
e.NULL
 Question:
What will be the output of the following code?
$foo = 5 + “10 things”;
print $foo;
?>
a.510 things
b.5 10 things
c.15 things
d.15   (Answer)
e.None of the above
 Question:
What will be the output of the following code?
$a = (1 << 0);
$b = (1 << $a);
$c = (1 << $b);
echo ($c || $b) << 2 * $a | $a;
?>
a.1
b.3
c.5  (Answer)
d.12
e.27
f.32
g.Syntax error
 Question:
Which fopen option opens the file for reading and writing; placing the file pointer at the beginning of the file without truncating it.
a.r
b.r+
c.w
d.W+
e.a
 Question:
What is the output of the following code?
echo  0500;
?>
a.100
b.500
c.0500
d.320
e.None of the above  (Answer)
 Question:
What is the size limit of strings in php?
a.1024bytes
b.100Mbytes
c.256Kbytes
d.There is no limit (hardware limit)   (Answer)
e.None of the above
 Question:
What kind of regular expression does PHP include?
a.PCRE
b.Java REGEX
c.Ruby REGEX
d.None of the above  (Answer)
 Question:
What is the output of the following code?
echo ’1′.print(2) + 3;
a.123
b.321
c.511  (Answer)
d.155
e.432
 Question:
Is the following code valid?
$a = 5;
if ($a == 5):
echo “Hello”;
echo “1″;
else:
echo “Not hello”;
echo “2″;
endif;
?>
a.yes  (Answer)
b.no
 Question:
Can PHP use Gettext?
a.yes  (Answer)
b.no
 Question:
What will be the output of the following code on a machine using IEEE 754 floats?
print (19.6*100) !== (double)1960;
?>
a.0
b.1  (Answer)
c.Nothing
d.Syntax error
 Question:
What will be the output of the following code?
$a = 3;
print ‘$a’;
?>
a.3
b.$a  (Answer)
c.Syntax error
d.None of the above

1 comment: