• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PHP Interview Questions Answers

Question - 121 : - What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

Answer - 121 : - mysql_fetch_array - Fetch a result row as an associative array and a numeric array. mysql_fetch_object - Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows mysql_fetch_row() - Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

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

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

Question - 123 : - How can we register the variables into a session?

Answer - 123 : - session_register($session_var); $_SESSION['var'] = 'value';

Question - 124 : - What is the difference between htmlentities() and htmlspecialchars()?

Answer - 124 : - htmlspecialchars() - Convert some special characters to HTML entities (Only the most widely used) htmlentities() - Convert ALL special characters to HTML entities

Question - 125 : - How come the code works, but doesn’t for two-dimensional array of mine?

Answer - 125 : - Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.

Question - 126 : - How do you define a constant?

Answer - 126 : - Via define() directive, like define ("MYCONSTANT", 100);

Question - 127 : - How can I retrieve values from one database server and store them in other database server using PHP?

Answer - 127 : - For this purpose, you can first read the data from one server into session variables. Then connect to other server and simply insert the data into the database.

Question - 128 : - How can we create a database using PHP and mysql?

Answer - 128 : - We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.

Question - 129 : - How can I execute a PHP script using command line?

Answer - 129 : - 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.

Question - 130 : - 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 - 130 : - PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners