• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PHP Interview Questions Answers

Question - 31 : - What are the different ways to login to a remote server? Explain the means, advantages and disadvantages?

Answer - 31 : - There is at least 3 ways to logon to a remote server: Use ssh or telnet if you concern with security You can also use rlogin to logon to a remote server. Please give a regular expression (preferably Perl/PREG style), which can be used to identify the URL from within a HTML link tag. Try this: /href="([^"]*)"/i

Question - 32 : - What’s the difference between accessing a class method via -> and via ::?

Answer - 32 : - :: is allowed to access methods that can perform static operations, i.e. those, which do not require object initialization.

Question - 33 : - What does a special set of tags <?= and ?> do in PHP?

Answer - 33 : - The output is displayed directly to the browser.

Question - 34 : - How to store the uploaded file to the final location?

Answer - 34 : - move_uploaded_file ( string filename, string destination) This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination. If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE. If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.

Question - 35 : - How to set cookies?

Answer - 35 : - setcookie('variable','value','time'); variable - name of the cookie variable value - value of the cookie variable time - expiry time Example: setcookie('Test',$i,time()+3600); Test - cookie variable name $i - value of the variable 'Test' time()+3600 - denotes that the cookie will expire after an one hour

Question - 36 : - 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 - 36 : - 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.

Question - 37 : - What is the difference between mysql_fetch_object and mysql_fetch_array?

Answer - 37 : - MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array

Question - 38 : - What Is a Session?

Answer - 38 : - A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

Question - 39 : - How can we know the number of days between two given dates using PHP?

Answer - 39 : - Simple arithmetic: $date1 = date('Y-m-d'); $date2 = '2006-07-01'; $days = (strtotime() - strtotime()) / (60 * 60 * 24); echo "Number of days since '2006-07-01': $days";

Question - 40 : - What is the functionality of the function htmlentities?

Answer - 40 : - htmlentities() - Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners