php with mysql interview Questions

PHP with mysql interview Questions with answers-- Asked at different competitive exams

Free Online test your knowledge on php and mysql programming exams. Each questions immediate answer or explanation given below, just click View answer button and also have option of Hide Answer button to hide answer. In this given upto 100+ questions and shows answer or explanation under of each question.
          Here all the questions and answers, most asked in different competitive exams and shows answers accordingly.
php and mysql interview questions with answers
Q11. What is the difference between mysql_fetch_object and mysql_fetch_array?

Answer/Explanation MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.

Q12. How can I execute a PHP script using command line?

Answer/Explanation Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, “php myScript.php”, assuming “php” is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

Q13. I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?

Answer: PHP Interpreter treats numbers beginning with 0 as octal.

Q14. Would I use print “$a dollars” or “{$a} dollars” to print out the amount of dollars in this example?

Solution: In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like “{$a},000,000 mln dollars”, then you definitely need to use the braces.

Q15. What are the different tables present in MySQL? Which type of table is generated when we are creating a table in the following syntax:
create table employee(eno int(2),ename varchar(10))?

Answer: Total 5 types of tables we can create
  1. MyISAM
  2. Heap
  3. Merge
  4. INNO DB
  5. ISAM
MyISAM is the default storage engine as of MySQL 3.23. When you fire the above
create query MySQL will create a MyISAM table.

Q16. How can we encrypt the username and password using PHP?

Answer1: You can encrypt a password with the following Mysql>SET
PASSWORD=PASSWORD(“Password”);
Answer2: You can use the MySQL PASSWORD() function to encrypt username and password.
For example
INSERT into user (password, …) VALUES (PASSWORD($password”)), …);

Q17. How do you pass a variable by value?

Answer: Just like in C++, put an ampersand in front of it, like $a = &$b;

Q18. WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?

Answer: string strstr ( string haystack, string needle ) returns part of haystack string from the first occurrence of needle to the end of haystack. This function is case-sensitive.
stristr() is idential to strstr() except that it is case insensitive.

Q19. When are you supposed to use endif to end the conditional statement?

Answer: When the original if was followed by : and then the code block without braces.

Q20. What is the functionality of the function strstr and stristr?

Answer: strstr() returns part of a given string from the first occurrence of a given substring to the end of the string.
For example:
strstr(“user@example.com”,”@”) will return
“@example.com”.
stristr() is idential to strstr() except that it is case insensitive.

More pages : Php Interview Questions

1 comment: