php mcq questions with answers


                                
The XML document below has been parsed into $xml via SimpleXMLHow can the value of <foo> tag accessed? <?xml version='1.0'?> <document> <bar> <foo>Value</foo> </bar> </document>
A.$xml->bar['foo']
B.$xml->bar->foo
C.$xml['document']['bar']['foo']
D.$xml->document->bar->foo
E.$xml->getElementByName('foo');
                                
The following form is loaded in a recent browser and submitted, with the second list element selected: <form method="post"> <select name="list"> <option>one</option> <option>two</option> <option>three</option> </select> </form> In the server-side PHP code to deal with the form data, what is the value of $_POST['list']?
A.1
B.2
C.two
D.null (since the <code> value attribute of the list has not been set)
                                
You are creating an application that repeatedly connects to a database to retrieve order data for invoicesAll data comes from the same databaseIn order to preserve resources, you have to ensure that only one database connection should be used at any timeThe code also has to open as few new database connections as possibleWhich design pattern should you use for this scenario?
A.Adapter
B.Factory
C.MVC
D.Singleton
                                
Which of the following code snippets writes the content of the file "source.txt" to "target.txt"?(Choose 3)
A.file_put_contents("target.txt", fopen("source.txt", "r"));
B.file_put_contents("target.txt", readfile("source.txt"));
C.file_put_contents("target.txt", join(file("source.txt"), ""));
D.file_put_contents("target.txt", file_get_contents("source.txt"));
E.$handle = fopen("target.txt", "w+"); fwrite($handle, file_get_contents("source.txt")); fclose($handle);
                                
Which of the following statements is NOT correct?
A.Only methods can have type hints
B.Typehints can be optional
C.Typehints can be references