ITTreats.com
Enter your Search term and Hit "Enter"

Thu, 11 Mar 2010 9:50:10 AM +00:00

Latest 'ITTreats'


PHP Interview Questions and Answers Part -6

PHP Interview Questions and Answers  Part -6

PHP Interview Questions and Answers Part-6

How many ways I can redirect a PHP page?

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]])

What type of headers have to be added in the mail function to attach a file?

$boundary = ‘–’ . md5( uniqid ( rand() ) );
$headers = “From: \”Me\”\n”;
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-Type: multipart/mixed; boundary=\”$boundary\”";

More . . .

PHP Interview Questions and Answers Part-5

PHP Interview Questions and Answers  Part-5

PHP Interview Questions and Answers Part-5

How can we get second of the current time using date function?

$second = date(“s”);

What is the maximum size of a file that can be uploaded using PHP and how can we change this?

You can change maximum size of a file set upload_max_filesize variable in php.ini file

How can I make a script that can be bilingual (supports English, German)?

You can change charset variable in above line in the script to support bilanguage. More . . .

PHP Interview Questions and Answers Part-4

PHP Interview Questions and Answers  Part-4

PHP Interview Questions and Answers Part-4

What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

Answer 1:
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().

Answer 2:
The difference between mysql_fetch_row() and mysql_fetch_array() is that the first returns the results in a numeric array ($row[0], $row[1], etc.), while the latter returns a the results an array containing both numeric and associative keys ($row['name'], $row['email'], etc.). mysql_fetch_object() returns an object ($row->name, $row->email, etc.).

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?

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. More . . .

PHP Interview Questions and Answers Part-3

PHP Interview Questions and Answers  Part-3

PHP Interview Questions and Answers Part-3

For printing out strings, there are echo, print and printf. Explain the differences.

echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like:

<?php echo ‘Welcome ‘, ‘to’, ‘ ‘, ‘fyicenter!’; ?>

and it will output the string “Welcome to fyicenter!” print does not take multiple parameters. It is also generally argued that echo is faster, but usually the speed advantage is negligible, and might not be there for future versions of PHP. printf is a function, not a construct, and allows such advantages as formatted output, but it’s the slowest way to print out data out of echo, print and printf. More . . .

PHP Interview Questions and Answers Part 2

PHP Interview Questions and Answers  Part 2

How can we send mail using JavaScript?

No. There is no way to send emails directly using JavaScript.

But you can use JavaScript to execute a client side email program send the email using the “mailto” code. Here is an example:

function myfunction(form)
{
tdata=document.myform.tbox1.value;
location=”mailto:mailid@domain.com?subject=…”;
return true;
}

What is the functionality of the function strstr and stristr?

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 . . .

PHP Interview Questions and Answers Part 1

PHP Interview Questions and Answers  Part 1

PHP Interview Questions and Answers Part-1

What’s PHP

The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.

What Is a Session?

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. More . . .