• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PHP Interview Questions Answers

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

Answer - 11 : - 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 - 12 : - How can we find the number of rows in a table using MySQL?

Answer - 12 : - Use this for MySQL SELECT COUNT(*) FROM table_name;

Question - 13 : - What are the advantages of stored procedures, triggers, indexes?

Answer - 13 : - A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients don't need to keep re-issuing the entire query but can refer to the stored procedure. This provides better overall performance because the query has to be parsed only once, and less information needs to be sent between the server and the client. You can also raise the conceptual level by having libraries of functions in the server. However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side. Triggers will also be implemented. A trigger is effectively a type of stored procedure, one that is invoked when a particular event occurs. For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted. Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks.

Question - 14 : - What are the features and advantages of OBJECT ORIENTED PROGRAMMING?

Answer - 14 : - One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns. For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

Question - 15 : - Will comparison of string "10" and integer 11 work in PHP?

Answer - 15 : - Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.

Question - 16 : - How can we submit from without a submit button?

Answer - 16 : - Trigger the JavaScript code on any event ( like onSelect of drop down list box, onfocus, etc ) document.myform.submit(); This will submit the form.

Question - 17 : - How many values can the SET function of MySQL take?

Answer - 17 : - MySQL SET function can take zero or more values, but at the maximum it can take 64 values.

Question - 18 : - What type of headers have to be added in the mail function to attach a file?

Answer - 18 : - $boundary = '--' . md5( uniqid ( rand() ) ); $headers = "From: \"Me\"\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";

Question - 19 : - What are the current versions of Apache, PHP, and MySQL?

Answer - 19 : - PHP: PHP 5.1.2 MySQL: MySQL 5.1 Apache: Apache 2.1

Question - 20 : - Explain about Type Juggling in php?

Answer - 20 : - PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer. An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated. $foo += 2; // $foo is now an integer (2) $foo = $foo + 1.3; // $foo is now a float (3.3) $foo = 5 + "10 Little Piggies"; // $foo is integer (15) $foo = 5 + "10 Small Pigs"; // $foo is integer (15) If the last two examples above seem odd, see String conversion to numbers. If you wish to change the type of a variable, see settype(). If you would like to test any of the examples in this section, you can use the var_dump() function. Note: The behavior of an automatic conversion to array is currently undefined. Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a? The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined. PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one presented above:

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners