PHP Interview Questions with Answers Part 3

on 12:48 AM

This is the third episode of PHP Interview Questions with answers. Check out this collection of PHP Interview Questions with simplified Answers..
  • How do you pass a variable by value?
  • WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?
  • When are you supposed to use endif to end the conditional statement?
  • How can we send mail using JavaScript?
  • What is the functionality of the function strstr and stristr?
  • What is the difference between ereg_replace() and eregi_replace()?
  • How do I find out the number of parameters passed into function9. ?
  • What is the purpose of the following files having extensions: frm, myd, and myi? What these files contain?
  • If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $b?
  • Write a query for the following question

 
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.
Write a query for the following question
The table tbl_sites contains the following data:

---------------------------------------
Userid sitename country
---------------------------------------
1 sureshbabu indian
2 PHPprogrammer andhra
3 PHP.net usa
4 PHPtalk.com germany
5 MySQL.com usa
6 sureshbabu canada
7 PHPbuddy.com pakistan
8. PHPtalk.com austria
9. PHPfreaks.com sourthafrica
10. PHPsupport.net russia
11. sureshbabu australia
12. sureshbabu nepal
13. PHPtalk.com italy

Write a select query that will be displayed the duplicated site name and how many times it is duplicated? …
SELECT sitename, COUNT(*) AS NumOccurrences
FROM tbl_sites
GROUP BY sitename HAVING COUNT(*) > 1

1 comments:

bartphpguru said...

Great resource! Find out more in here,
http://www.phpinterviewquestions.com

Post a Comment