Pages

About Me

My photo
Kulrian/Bareta, Punjab, India
I am simple and coool boy.

Saturday 5 September 2009

PHP interview Questions

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.

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("");
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("");
?>

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

What are the differences between DROP a table and TRUNCATE a table?
DROP TABLE table_name - This will delete the table and its data.

TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition.

How do you call a constructor for a parent class?
parent::constructor($value)

WHAT ARE THE DIFFERENT TYPES OF ERRORS IN PHP?
Here are three basic types of runtime errors in PHP:

1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although you can change this default behavior.

2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behavior is to display them to the user when they take place.

Internally, these variations are represented by twelve different error types

What’s the special meaning of __sleep and __wakeup?
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.

How can we submit a form without a submit button?
If you don't want to use the Submit button to submit a form, you can use normal hyper links to submit a form. But you need to use some JavaScript code in the URL of the link. For example:

Submit Me

No comments:

Post a Comment