• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

PHP Interview Questions Answers

Question - 111 : - How many ways I can redirect a PHP page?

Answer - 111 : - Here are the possible ways of php page redirection. 1. Using Java script: '; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http://maosjb.com'); ?> 2. Using php function: header("Location:http://maosjb.com "); List out different arguments in PHP header function? void header ( string string [, bool replace [, int http_response_code]])

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

Answer - 112 : - mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array. mysql_fetch_object() -> Fetch a result row as an object. mysql_fetch_row() -> Fetch a result set as a regular array().

Question - 113 : - If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?

Answer - 113 : - Session depends on browser. If browser is closed then session is lost. The session data will be deleted after session time out. If connection is lost and you recreate connection, then session will continue in the browser.

Question - 114 : - How can we destroy the session, how can we unset the variable of a session?

Answer - 114 : - session_unregister() - Unregister a global variable from the current session session_unset() - Free all session variables

Question - 115 : - What are the different functions in sorting an array?

Answer - 115 : - Sorting functions in PHP: asort() arsort() ksort() krsort() uksort() sort() natsort() rsort()

Question - 116 : - What are encryption functions in PHP?

Answer - 116 : - CRYPT() MD5()

Question - 117 : - What Is a Persistent Cookie?

Answer - 117 : - A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences: *Temporary cookies can not be used for tracking long-term information. *Persistent cookies can be used for tracking long-term information. *Temporary cookies are safer because no programs other than the browser can access them. *Persistent cookies are less secure because users can open cookie files see the cookie values.

Question - 118 : - How can I set a cron and how can I execute it in Unix, Linux, and windows?

Answer - 118 : - Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it's called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time. The easiest way to use crontab is via the crontab command. # crontab This command 'edits' the crontab. Upon employing this command, you will be able to enter the commands that you wish to run. My version of Linux uses the text editor vi. You can find information on using vi here. The syntax of this file is very important – if you get it wrong, your crontab will not function properly. The syntax of the file should be as follows: minutes hours day_of_month month day_of_week command All the variables, with the exception of the command itself, are numerical constants. In addition to an asterisk (*), which is a wildcard that allows any value, the ranges permitted for each field are as follows: Minutes: 0-59 Hours: 0-23 Day_of_month: 1-31 Month: 1-12 Weekday: 0-6 We can also include multiple values for each entry, simply by separating each value with a comma. command can be any shell command and, as we will see momentarily, can also be used to execute a Web document such as a PHP file. So, if we want to run a script every Tuesday morning at 8:15 AM, our mycronjob file will contain the following content on a single line: 15 8 * * 2 /path/to/scriptname This all seems simple enough, right? Not so fast! If you try to run a PHP script in this manner, nothing will happen (barring very special configurations that have PHP compiled as an executable, as opposed to an Apache module). The reason is that, in order for PHP to be parsed, it needs to be passed through Apache. In other words, the page needs to be called via a browser or other means of retrieving Web content. For our purposes, I'll assume that your server configuration includes wget, as is the case with most default configurations. To test your configuration, log in to shell. If you're using an RPM-based system (e.g. Redhat or Mandrake), type the following: Question - 119 : - What is the use of friend function?

Answer - 119 : - Friend functions Sometimes a function is best shared among a number of different classes. Such functions can be declared either as member functions of one class or as global functions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of that class. A friend declaration is essentially a prototype for a member function, but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member function of another class provides the match. class mylinkage { private: mylinkage * prev; mylinkage * next; protected: friend void set_prev(mylinkage* L, mylinkage* N); void set_next(mylinkage* L); public: mylinkage * succ(); mylinkage * pred(); mylinkage(); }; void mylinkage::set_next(mylinkage* L) { next = L; } void set_prev(mylinkage * L, mylinkage * N ) { N->prev = L; } Friends in other classes It is possible to specify a member function of another class as a friend as follows: class C { friend int B::f1(); }; class B { int f1(); }; It is also possible to specify all the functions in another class as friends, by specifying the entire class as a friend. class A { friend class B; }; Friend functions allow binary operators to be defined which combine private data in a pair of objects. This is particularly powerful when using the operator overloading features of C++. We will return to it when we look at overloading.

Question - 120 : - What are the MySQL database files stored in system ?

Answer - 120 : - Data is stored in name.myd Table structure is stored in name.frm Index is stored in name.myi

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners