Sample questions
Question 1Medium
The __ function creates a directory on the FTP server.
ftp_mkdir()ftp_makekdir()ftp_mkdirectory()- Both A & B
Answer: A. ftp_mkdir()
Explanation
ftp_mkdir() Creates the specified directory on the FTP server.
Syntax:-
string ftp_mkdir ( resource $ftp_stream, string $directory )
Step-by-step solution
- The question asks for the FTP function that creates a directory on the server.
- Ftp_mkdir takes the FTP connection and a directory name.
- Ftp_makekdir and ftp_mkdirectory are not PHP functions, so Both A and B is wrong.
- The correct answer is option A, ftp_mkdir.
Why the other options are wrong
- B. Ftp_makekdir is not a PHP function; the name is ftp_mkdir.
- C. Ftp_mkdirectory is not a PHP function; the name is ftp_mkdir.
- D. Option B is not a real function, so A and B cannot both be right.
Tip: FTP functions in PHP start with ftp_ and use short verbs such as mkdir.
Question 2Medium
What function can you use to create your own streams using the PHP stream wrappers and register them within PHP?
- wrapper register
- stream wrapper
- stream_wrapper_register
- stream_wrapper_reg
Answer: C. stream_wrapper_register
Explanation
stream_wrapper_register Register a URL wrapper implemented as a PHP class. It Allows you to implement your own protocol handlers and streams for use with all the other file system functions (such as fopen(), fread() etc.).
Step-by-step solution
- The question asks for the function that registers a custom stream wrapper class with PHP.
- The explanation says stream_wrapper_register registers a URL wrapper implemented as a PHP class.
- So the answer is stream_wrapper_register, option C.
Why the other options are wrong
- A. Wrapper register is not a PHP function name.
- B. Stream wrapper is a concept, not a function.
- D. Stream_wrapper_reg is a misspelled name; the function is stream_wrapper_register.
Tip: PHP function names are written in full with underscores; check the spelling in each option.
Question 3Medium
When dealing with timeout values in sockets, the connection timeout can be changed independently of the read/write time out. Which function must be used for this purpose?
- stream_get_timeout
- stream_set_timeout
- stream_fset_timeout
- stream_fget_timeout
Answer: B. stream_set_timeout
Explanation
Sets the timeout value on stream, expressed in the sum of seconds and microseconds.
Syntax: bool stream_set_timeout ( resource $stream, int $seconds [, int $microseconds = 0 ] )
Step-by-step solution
- The question asks for the function that sets the timeout value on a stream.
- The names stream_get_timeout, stream_fset_timeout and stream_fget_timeout are not the setter.
- Stream_set_timeout takes the stream, seconds and an optional microseconds value.
- The correct answer is option B, stream_set_timeout.
Why the other options are wrong
- A. The get name suggests reading a value, and it is not the function that sets the timeout.
- C. This name is not the setter; the setter is stream_set_timeout.
- D. The fget name suggests reading a value, not setting one.
Tip: In PHP function names, set means change a value and get means read one; match the verb in the question.
Question 4Medium
The __ function returns the size of a specified file on the FTP server.
- get_ftp_size()
- ftp_file_size()
- ftp_size()
- ftp_amount()
Answer: C. ftp_size()
Explanation
ftp_size() returns the size in bytes of a file on the FTP server, or -1 on error. It takes the FTP connection and the file name. The other names are not PHP functions.
Step-by-step solution
- The question asks for the function that gets a file's size from an FTP server.
- Option C is '
ftp_size()', which directly refers to getting file size. - Other options like
get_ftp_size() or ftp_file_size() are not standard functions for this purpose. - The correct answer matches the given explanation about
ftp_size(). - Final answer:
ftp_size()
Why the other options are wrong
- A. get_ftp_size() is not a PHP function name; the real one is ftp_size().
- B. ftp_file_size() is not a PHP function name; ftp_size() returns the file size.
- D. ftp_amount() is not a PHP function; the size call is ftp_size().
Tip: Remember 'ftp_size()' for getting file sizes in FTP.
Question 5Medium
How can I run com object from remote server?
- like we run local objects
- pass the IP of the remote machine as first parameter to the COM constructor.
- pass the IP of the remote machine as second parameter to the COM constructor.
- Both a and c above
Answer: D. Both a and c above
Explanation
A remote COM object is created the same way as a local one. You pass the IP address or name of the remote machine as the second parameter of the COM constructor, and com.allow_dcom must be TRUE in php.ini. Option B gives the address in the wrong position.
Step-by-step solution
- A COM object on a remote machine is used the same way as a local one (option A is true).
- The remote machine's address is passed as the second parameter to the COM constructor (option C is true).
- Options a and c are both true, so the correct answer is option D, both a and c.
Why the other options are wrong
- B. The address goes in the second parameter, not the first, so this is wrong.
Tip: For remote COM, the server name is the second argument to the COM constructor, and com.allow_dcom must be on.
Question 6Medium
The FTP functions are used to ....... files from file servers.
- Login
- Upload
- Download
- All of above
Answer: D. All of above
Explanation
The FTP functions are used to open, login and close connections, as well as upload, download, rename, delete, and get information on files from file servers. Not all of the FTP functions will work with every server or return the same results. The FTP functions became available with PHP 3.
Step-by-step solution
- FTP functions open, log in to and close connections.
- They also upload, download, rename, delete and get information on files on file servers.
- Upload and download both fit the blank, so the answer is option D, All of above.
Why the other options are wrong
- A. Login is a connection step, not a file transfer, so it is only part of the answer.
- B. Upload is correct, but download is also correct, so this option is incomplete.
- C. Download is correct, but upload is also correct, so this option is incomplete.
Tip: When two listed options are both true, pick the one that covers all of them.
Question 7Medium
Which of the following network transports does not have PHP support?
- tcp
- udp
- udg
- pdc
Answer: D. pdc
Explanation
List of Supported Socket Transports :-
1.Internet Domain: TCP, UDP, SSL, and TLS
2. Unix Domain: Unix and UDG
Step-by-step solution
- PHP supports Internet Domain transports like TCP and UDP.
- PHP also supports Unix Domain transports like Unix and UDG.
- PDC is not listed as a supported socket transport in PHP.
- Therefore, PDC does not have PHP support.
- Final answer: pdc.
Why the other options are wrong
- A. tcp is an Internet domain transport that PHP supports for sockets.
- B. udp is an Internet domain transport that PHP supports for sockets.
- C. udg is a Unix domain datagram transport that PHP supports for sockets.
Tip: Remember key supported transports: TCP, UDP, Unix, UDG.
Question 8Medium
The windows version of PHP has built-in support for the FTP extension
- True
- False
Answer: A. True
Explanation
The windows version of PHP has built-in support for the FTP extension. So, the FTP functions will work automatically. However, if you are running the Linux version of PHP, you will have to compile PHP with --enable-ftp (PHP 4+) or --with-ftp (PHP 3) to get the FTP functions to work.
Step-by-step solution
- The question asks whether the Windows build of PHP has built-in FTP support.
- The explanation says the Windows version has built-in FTP support, so FTP functions work automatically.
- So the statement is True, which is option A.
Why the other options are wrong
- B. The statement is true according to the explanation, so False is wrong.
Tip: On Windows the FTP functions work out of the box; on Linux the extension may need to be enabled.
Question 9Medium
What will the following script do?
<?php echo getservbyname ('ftp', 'tcp');
?>
- A list of the FTP servers on the local network
- The address of the FTP server called 'tcp'
- The port associated with the TCP service called 'FTP'
- A list of the ports associated with all services except FTP
Answer: C. The port associated with the TCP service called 'FTP'
Explanation
getservbyname() returns the Internet port which corresponds to service for the specified protocol as per /etc/services.
SYNTAX: int getservbyname ( string $service, string $protocol )
Step-by-step solution
- Getservbyname takes 'ftp' and 'tcp' as inputs.
- 'ftp' is the service name, 'tcp' is the protocol.
- It returns the port number for TCP FTP service.
- Port numbers are integers, not addresses or lists.
- The output is the port associated with TCP FTP.
Why the other options are wrong
- A. The script does not list FTP servers; getservbyname() looks up the port number for a service.
- B. tcp is the protocol here, not a server name, so the script does not return an address.
- D. The script returns one port for FTP, not a list of ports for all other services.
Tip: Remember: getservbyname returns a port number for a service and protocol.
Practise all 9 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →