PHP Interview Questions and Answers
Question - 21 : - What is the functionality of the functions STRSTR() and STRISTR()?
Answer - 21 : - 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.
Question - 22 : - When are you supposed to use endif to end the conditional statement?
Answer - 22 : - When the original if was followed by : and then the code block without braces.
Question - 23 : - How can we send mail using JavaScript?
Answer - 23 : - 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;
}
Question - 24 : - What is the functionality of the function strstr and stristr?
Answer - 24 : - 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.
Question - 25 : - What is the difference between ereg_replace() and eregi_replace()?
Answer - 25 : - eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.
Question - 26 : - How do I find out the number of parameters passed into function9. ?
Answer - 26 : - func_num_args() function returns the number of parameters passed in.
Question - 27 : - What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
Answer - 27 : - 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.
Question - 28 : - How To Protect Special Characters in Query String?
Answer - 28 : - If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():
");
print("
Please click the links below"
." to submit comments about TECHPreparation.com:
");
$comment = 'I want to say: "It\'s a good site! :->"';
$comment = urlencode($comment);
print("
"
.""
."It's an excellent site!
");
$comment = 'This visitor said: "It\'s an average site! :-("';
$comment = urlencode($comment);
print("
"
.''
."It's an average site.
");
print("