Thursday, 26 April 2012

PHP Interview question 2


6)What is urlencode and urldecode?
Urlencode can be used to encode a string that can be used in a url. It encodes the same way posted data from web page is encoded. It returns the encoded string.
Syntax: urlencode (string $str )
Urldecode can be used to decode a string. Decodes any %## encoding in the given string (Inserted by urlencode)
Syntax: urldecode (string $str )

7)What are the different types of errors in PHP?

Different types of errors are:
E_ERROR: A fatal error that causes script termination
E_WARNING: Run-time warning that does not cause script termination
E_PARSE: Compile time parse error.
E_NOTICE: Run time notice caused due to error in code
E_CORE_ERROR: Fatal errors that occur during PHP's initial startup (installation)
E_CORE_WARNING: Warnings that occur during PHP's initial startup 
E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
E_USER_ERROR: User-generated error message. 
E_USER_WARNING: User-generated warning message. 
E_USER_NOTICE: User-generated notice message. 
E_STRICT: Run-time notices.
E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
E_ALL: Catches all errors and warnings 

8)Explain how to submit form without a submit button.
A form data can be posted or submitted without the button in the following ways:
1. On OnClick event of a label in the form, a JavaScript function can be called to submit the form
e.g. document.form_name.submit()
2. Using a Hyperlink: On clicking the link, JavaScript function can be called
e.g <a.href=” javascript:document.MyForm.submit();">

9)What are the functions for IMAP?
IMAP is used for communicate with mail servers. It has a number of functions. Few of them are listed below:
Imap_alerts – Returns all the imap errors occurred
Imap_body – Reads the message body
Imap_check – Reads the current mail box
Imap_clearflag_full – Clears all flags
Imap_close – close and IMAP stream
Imap_delete – Delete message from current mailbox
Imap_delete_mailbox – Deletes a mailbox
Imap_fetchbody – Fetches body of message
Imap_fetchheader – Fetches header of message
Imap_headers – Returns headers for ALL messages
Imap_mail : send a mail
Imap_sort- Sorts imap messages

10)How can we increase the execution time of a php script?
Default time allowed for the PHP scripts to execute is 30s defined in the php.ini file. The function used is set_time_limit(int seconds). If the value passed is ‘0’, it takes unlimited time. It should be noted that if the default timer is set to 30 sec and 20 sec is specified in set_time_limit(), the script will run for 45 secs.

No comments:

Post a Comment