Monday, April 14, 2008

Php interview questions - part4

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”)), ...);

How do you pass a variable by value?

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

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

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.

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

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

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.

What is the difference between ereg_replace() and eregi_replace()?

eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.

How do I find out the number of parameters passed into function9. ?

func_num_args() function returns the number of parameters passed in.

What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?

In MySQL, the default table type is MyISAM.
Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type.

The '.frm' file stores the table definition.
The data file has a '.MYD' (MYData) extension.
The index file has a '.MYI' (MYIndex) extension,

If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?

100, it’s a reference to existing variable.

No comments: