php mcq questions with answers


                                
Which of the following commands will append data to an existing file?
A.file_put_contents("file", "data", "a");
B.file_put_contents("file", "a", "data");
C.file_put_contents("file", "data", FILE_APPEND);
D.file_put_contents("file", "a", NULL, FILE_APPEND);
                                
Which PHP function retrieves a list of HTTP headers that have been sent as part of the HTTP response or are ready to be sent?
A.header()
B.headers()
C.headers_list()
D.headers_sent()
                                
What is the return value of the following code? strpos("me myself and I", "m", 2)
A.2
B.3
C.4
D.0
E.1
                                
How can the id attribute of the 2nd baz element from the XML string below be retrieved from the SimpleXML object found inside $xml? <?xml version='1.0'?> <foo> <bar> <baz id="1">One</baz> <baz id="2">Two</baz> </bar> </foo>
A.$xml->getElementById('2');
B.$xml->foo->bar->baz[2]['id']
C.$xml->foo->baz[2]['id']
D.$xml->foo->bar->baz[1]['id']
E.$xml->bar->baz[1]['id']
                                
What is the output of the following script? <?php function fibonacci (&$x1 = 0, &$x2 = 1) { $result = $x1 + $x2; $x1 = $x2; $x2 = $result; return $result; } for ($i = 0; $i < 10; $i++) { echo fibonacci() ','; } ?>
A.An error
B.1,1,1,1,1,1,1,1,1,1,
C.1,1,2,3,5,8,13,21,34,55,
D.Nothing