• +91 9971497814
  • info@interviewmaterial.com

PHP Interview Questions Answers

Question 1 :  How can we encrypt and decrypt a data presented in a table using MySQL?

Answer 1 : You can use functions: AES_ENCRYPT() and AES_DECRYPT() like: AES_ENCRYPT(str, key_str) AES_DECRYPT(crypt_str, key_str)

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

Answer 2 : Everything is passed by value.

Question 3 : Can we use include ("abc.php") two times in a php page "makeit.php"?

Answer 3 : Yes.

Question 4 : Can we use include(abc.PHP) two times in a PHP page makeit.PHP”?

Answer 4 : Yes we can include that many times we want, but here are some things to make sure of: (including abc.PHP, the file names are case-sensitive) there shouldn't be any duplicate function names, means there should not be functions or classes or variables with the same name in abc.PHP and makeit.php

Question 5 : Check if a variable is an integer in JAVASCRIPT ?

Answer 5 : var myValue =9.8; if(parseInt(myValue)== myValue) alert('Integer'); else alert('Not an integer'); Tools used for drawing ER diagrams. Case Studio Smart Draw

Question 6 : Explain about Type Juggling in php?

Answer 6 : 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:

Question 7 : Explain normalization concept?

Answer 7 : The normalization process involves getting our data to conform to three progressive normal forms, and a higher level of normalization cannot be achieved until the previous levels have been achieved (there are actually five normal forms, but the last two are mainly academic and will not be discussed). First Normal Form The First Normal Form (or 1NF) involves removal of redundant data from horizontal rows. We want to ensure that there is no duplication of data in a given row, and that every column stores the least amount of information possible (making the field atomic). Second Normal Form Where the First Normal Form deals with redundancy of data across a horizontal row, Second Normal Form (or 2NF) deals with redundancy of data in vertical columns. As stated earlier, the normal forms are progressive, so to achieve Second Normal Form, your tables must already be in First Normal Form. Third Normal Form I have a confession to make; I do not often use Third Normal Form. In Third Normal Form we are looking for data in our tables that is not fully dependant on the primary key, but dependant on another value in the table

Question 8 : Explain the ternary conditional operator in PHP?

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

Question 9 : Give the syntax of GRANT commands?

Answer 9 : The generic syntax for GRANT is as following GRANT [rights] on [database] TO [username@hostname] IDENTIFIED BY [password] Now rights can be: a) ALL privilages b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc.

Question 10 : Give the syntax of REVOKE commands?

Answer 10 : The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privileges b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc. We can grant rights on all database by using *.* or some specific database by database.* or a specific table by database.table_name.

PHP Contributors


Share your email for latest updates


Our partners