PHP Questions and Answers Part-22

1. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the following statement will you use?
a) upload_tmp_dir “/tmp/phpuploads/ directory”
b) upload_dir “/tmp/phpuploads/ directory”
c) upload_temp_dir “/tmp/phpuploads/ directory”
d) upload_temp_director “/tmp/phpuploads/ directory”

Answer: a
Explanation: Anyone can temporarily store uploaded files on the given directory. One cannot change upload_tmp_dir at the runtime. By the time a script runs, the upload process has already occurred.

2. Which superglobal stores a variety of information pertinent to a file uploaded to the server via a PHP script?
a) $_FILE Array
b) $_FILES Array
c) $_FILES_UPLOADED Array
d) $_FILE_UPLOADED Array

Answer: b
Explanation: The superglobal $_FILES is a two-dimensional associative global array of items which are being uploaded by via HTTP POST method and holds the attributes of files.

3. How many items are available in the $_FILES array?
a) 2
b) 3
c) 4
d) 5

Answer: d
Explanation: $_FILEs[‘userfile’][‘error’], $_FILEs[‘userfile’][‘name’], $_FILEs[‘userfile’][‘size’], $_FILEs[‘userfile’][‘tmp_name’], $_FILEs[‘userfile’][‘type’] are the five items in the array.

4. Which function is used to determine whether a file was uploaded?
a) is_file_uploaded()
b) is_uploaded_file()
c) file_uploaded(“filename”)
d) uploaded_file(“filename”)

Answer: b
Explanation: The function is_uploaded_file() checks whether the specified file is uploaded via HTTP POST. The syntax is is_uploaded_file(file).

5. What is the full form of DNS?
a) Digital Network System
b) Domain Network System
c) Digital Name Systmem
d) Domain Name System

Answer: d
Explanation: DNS stands for domain name system. It is the way that internet domain names are located and translated into internet protocol (IP) addresses. For example, if someone types abc.com into the web browser, a server behind the scenes will map that name to the IP address 206.16.49.139.

6. Which one of the following function checks for the existence of DNS records?
a) checkdns()
b) checkdnsr()
c) checkdnsrr()
d) checkdnsa()

Answer: c
Explanation: The function checkdnsrr() is used to check DNS records for type corresponding to host. DNS records are checked based on the supplied host value and optional DNS resource record type, returning TRUE if any records are located and FALSE otherwise.

7. Which one of the following function is used to return an array consisting of various DNS resource records pertinent to a specific domain?
a) dns_get_record()
b) dns_record()
c) dnsrr_get_record()
d) dnsrr_record()

Answer: a
Explanation: The function dns_get_record() is used to get the DNS resource records associated with the specified hostname. This function is used to return an array consisting of various DNS resource records pertinent to a specific domain.

8. Which one of the following function is used to retrieve the MX records for the domain specified by hostname?
a) getmx()
b) retrieve_mx()
c) getmxrr()
d) retrieve_mxrr()

Answer: c
Explanation: The function getmxrr() returns the MX records for the specified internet host name. This function is used to retrieve the MX records for the domain specified by hostname.

9. What is the default port number of HTTPs?
a) 70
b) 80
c) 90
d) 100

Answer: b
Explanation: By default, The port number HTTP uses is port 80 and HTTPS uses port 443, but a URL like http://www.abc.com:8080/path/ specifies that the web browser connects instead to port 8080 of the HTTP servers.

10. Which one of the following function returns the port number of a specified service?
a) getportname()
b) getservername()
c) getserverbyname()
d) getservbyname()

Answer: d
Explanation: The function fgetservbyname() returns the port number for a given Internet service and protocol. Example-getservbyname(“http”,”tcp”) will return 80.