PHP Interview Questions and Answers – Part 8

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

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

123. 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)
return true;

124. 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(“”,”@”) will return “”.
stristr() is idential to strstr() except that it is case insensitive.

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

126. How do I find out the number of parameters passed into function. ?
func_num_args() function returns the number of parameters passed in.

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

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

129. How To Protect Special Characters in Query String?
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(“<p>Please click the links below”
.” to submit comments about</p>”);
$comment = ‘I want to say: “It\’s a good site! :->”‘;
$comment = urlencode($comment);
.”<a href=\”processing_forms.php?name=Guest&comment=$comment\”>”
.”It’s an excellent site!</a></p>”);
$comment = ‘This visitor said: “It\’s an average site!  “‘;
$comment = urlencode($comment);
.’<a href=”processing_forms.php?’.$comment.’”>’
.”It’s an average site.</a></p>”);

130. Are objects passed by value or by reference?
Everything is passed by value.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

+ one = 3

Popup Dialog Box Powered By :
  • RSS
  • Facebook
  • Google+
  • Twitter