91-9990449935 0120-4256464 |
PHP Interview QuestionsThere is given PHP interview questions and answers that has been asked in many companies. Let's see the list of top PHP interview questions. 1) What is PHP?PHP stands for Hypertext Preprocessor. It is an open source server-side scripting language that is widely used for web development. It supports many databases like MySQL, Oracle, Sybase, Solid, PostgreSQL, generic ODBC etc. 2) What is PEAR in PHP?PEAR is a framework and repository for reusable PHP components. PEAR stands for PHP Extension and Application Repository. It contains all types of PHP code snippets and libraries. It also provide a command line interface to install "packages" automatically. 3) Who is known as the father of PHP?Rasmus Lerdorf 4) What was the old name of PHP?Personal Home Page. 5) Explain the difference b/w static and dynamic websites?In static websites, content can't be changed after running the script. You can't change anything in the site. It is predefined. In dynamic websites, content of script can be changed at the run time. Its content regenerated every time the user visit or reload. Google, yahoo and every search engine is the example of dynamic website. 6) What is the name of scripting engine in PHP?The scripting engine that powers PHP is called Zend Engine 2. 7) Explain the difference between PHP4 and PHP5.PHP4 doesn't support oops concept and uses Zend Engine 1. PHP5 supports oops concept and uses Zend Engine 2. 8) What are the methods of form submitting in PHP?There are two methods GET and POST. 9) What is a session?PHP Engine creates a logical object to preserve data across subsequent HTTP requests, which is known as session. Sessions generally store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same user. Simply, it maintains data of an user (browser). 10) What is the method to register a variable into a session?11) What are the encryption functions in PHP?CRYPT() and MD5() 12) What are the different types of errors in PHP?There are 3 types of error in PHP. Notices:These are the non-critical errors. These errors are not displayed to the users. Warnings:These are more serious errors but they do not result in script termination. By default, these errors are displayed to the user. Fatal Errors:These are the most critical errors. These errors may be a cause of immediate termination of script. 13) What is the difference between $message and $$message?$message stores variable data while $$message is used to store variable of variables. $message stores fixed data whereas the data stored in $$message may be changed dynamically. 14) What is the difference between "echo" and "print" in PHP?Echo can output one or more string but print can only output one string and always returns 1. Echo is faster than print because it does not return any value. 15) How do you connect MySQL database with PHP?There are two methods to connect MySQL database with PHP. Procedural and object oriented style. 16) Differentiate between require and include?Require and include both are used to include a file, but if file is not found include sends warning whereas require sends Fatal error. 17) Which programming language does PHP resemble to?PHP has borrowed its syntax from Perl and C. 18) What is the method to execute a PHP script from the command line?You should just run the PHP command line interface (CLI) and specify the file name of the script to be executed as follows. 19) What is the use of count() function in PHP?Count() function is used to count total elements in the array, or something an object. 20) What is the difference between session and cookie?The main difference between session and cookies is that cookies are stored on the user's computer in the text file format while sessions are stored on the server side. Cookies can?t hold multiple variables on the other hand Session can hold multiple variables. You can manually set an expiry for a cookie, while session only remains active as long as browser is open. 21) How can you retrieve a cookie value?22) What are the different loops in PHP?For, while, do-while and for each. 23) What is the use of header() function in PHP?The header() function is used to send a raw HTTP header to a client. It must be called before sending the actual output. For example, you can't print any HTML element before using this function. 24) What is the array in PHP?Array is used to store multiple values in single value. In PHP, it orders maps of pairs of keys and values. It stores the collection of data type. 25) How can you submit a form without a submit button?You can use JavaScript submit() function to submit the form without explicitly clicking any submit button. 26) What does isset() function?The isset() function checks if the variable is defined and not null. 27) How to get the length of string?The strlen() function is used to get the length of string. 28) How can you send email in PHP?The mail() function is used to send email in PHP. 29) What is the difference between indexed and associative array?The indexed array holds elements in an indexed form which is represented by number starting from 0 and incremented by 1. For example: The associative array holds elements with name. For example: 30) How to upload file in PHP?The move_uploaded_file() function is used to upload file in PHP. 31) How to download file in PHP?The readfile() function is used to download file in PHP. 32) How to delete file in PHP?The unlink() function is used to delete file in PHP. 33) How to create connection in PHP?The mysqli_connect() function is used to create connection in PHP. 34) How to stop the execution of PHP script?The exit() function is used to stop the execution of PHP script. 35) What are the popular Content Management Systems (CMS) in PHP?
36) What are the popular frameworks in PHP?
|