• +91 9971497814
  • info@interviewmaterial.com

PHP Interview Questions Answers

Question 1 : What’s the difference between include and require?

Answer 1 : It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

Question 2 : Explain the ternary conditional operator in PHP?

Answer 2 : Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.

Question 3 : How many ways I can redirect a PHP page?

Answer 3 : Here are the possible ways of php page redirection. 1. Using Java script: '; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http://maosjb.com'); ?> 2. Using php function: header("Location:http://maosjb.com "); List out different arguments in PHP header function? void header ( string string [, bool replace [, int http_response_code]])

Question 4 : How to store the uploaded file to the final location?

Answer 4 : move_uploaded_file ( string filename, string destination) This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination. If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE. If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.

Question 5 : How can I use the COM components in php?

Answer 5 : The COM class provides a framework to integrate (D)COM components into your PHP scripts. string COM::COM( string module_name [, string server_name [, int codepage]]) - COM class constructor. Parameters: module_name: name or class-id of the requested component. server_name: name of the DCOM server from which the component should be fetched. If NULL, localhost is assumed. To allow DCOM com, allow_dcom has to be set to TRUE in php.ini. codepage - specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL, CP_THREAD_ACP, CP_UTF7 and CP_UTF8. Usage: $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff $word->Selection->TypeText("This is a test…"); $word->Documents[1]->SaveAs("Useless test.doc"); //closing word $word->Quit(); //free the object $word->Release(); $word = null;

Question 6 : What changes I have to do in php.ini file for file uploading?

Answer 6 : Make the following line uncomment like: ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). upload_tmp_dir = C:\apache2triad\temp ; Maximum allowed size for uploaded files. upload_max_filesize = 2M

Question 7 : What is the default session time in php and how can I change it?

Answer 7 : The default session time in php is until closing of browser

Question 8 : Are objects passed by value or by reference?

Answer 8 : Everything is passed by value.

Question 9 : What type of inheritance that php supports?

Answer 9 : In PHP an extended class is always dependent on a single base class, that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.

Question 10 : How many ways we can give the output to a browser?

Answer 10 : HTML output PHP, ASP, JSP, Servlet Function Script Language output Function Different Type of embedded Package to output to a browser  

PHP Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners