• +91 9971497814
  • info@interviewmaterial.com

PHP Interview Questions Answers

Question 1 : How can increase the performance of MySQL select query?

Answer 1 : We can use LIMIT to stop MySql for further search in table after we have received our required no. of records, also we can use LEFT JOIN or RIGHT JOIN instead of full join in cases we have related data in two or more tables.

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

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

Question 3 : What type of inheritance that php supports?

Answer 3 : 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 4 : Are objects passed by value or by reference?

Answer 4 : Everything is passed by value.

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

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

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 : How can I use the COM components in php?

Answer 7 : 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 8 : How to store the uploaded file to the final location?

Answer 8 : 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 9 : How many ways I can redirect a PHP page?

Answer 9 : 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 10 : Explain the ternary conditional operator in PHP?

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

PHP Contributors


Share your email for latest updates


Our partners