1.About registry_globals in PHP
register_globals is disabled in your PHP configuration. This can be enabled in your php.ini
configuration file or in the .htaccess file in your catalog directory.
2.destructors in PHP
PHP also allows you to define class destructors - a function to be called when an object is deleted. PHP calls destructors as soon as objects are no longer available, and the destructor function, __destruct(), takes no parameters.Like constructors, destructors are only called once - you need to use parent::__destruct(). The key difference is that you should call parent::__destruct() after the local code for the destruction so that you are not destroying variables before using it.
Destructors are useful to free up resources once you are done with them, but they are also good for keeping track of your objects - you can perform any actions you want in destructors, so take advantage of them!
3.cookies:
1.store session data(login information,pages visited,shopping cart)
2.track users who visit your website.
2.Allows users to personalixe the information.
4.Trim in JavaScript
Trim function in JavaScript for cleaning up extra white spaces around a piece of text
eg:This function uses a while loop
function TrimUsingWhileLoop(str)
{ while(str.charAt(0) == (" ") )
{ str = str.substring(1);
}
while(str.charAt(str.length-1) == " " )
{ str = str.substring(0,str.length-1);
}
return str;
}
Working of trim function
Basically, this is how a trim function works. First, the code must identify the first character of the string it is operating on,and if that first character is a whitespace character, delete it and save the string. Then repeat this process over and overagain, until there are no more whitespace characters at the front of the string. Next, the function should repeat this process at the end of the string to remove all whitespace characters at the end.
5.Difference between include() and include_once()
include() will always include the file every time it’s called, even if it’s the same file, while include_once() will only include the file once.so to be on the safe side using include_once() is just better
6.Difference between require() and require_once()
require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example.
7.Difference between require() and include()
require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.
8. What are the differences between Get and post methods in form submitting, give the case where we can use get and we can use post methods?
get is like query string all the variables will be displayed in he url
where as post is the standard way of sending th evariables
When we submit a form, which has the GET method it displays pair of name/value used in the form at the address bar of the browser preceded by url. Post method doesn’t display these values.
9.Who is the father of PHP and explain the changes in PHP versions?
Father of php is Rasmus Lerdorf
10. How can we submit a form without a submit button?
Ans : I can submit a form in many ways, for e.g.
1. When user click on checkbox, or drop down
2. When user click on radio button
3. At the end of the form I will type “Click here
to submit” & link text to the processing file
form.submit();
11. What function would you use to redirect the browser to a new page?
1. redir()
2. header()
3. location()
4. redirect()
12. What function can you use to open a file for reading and writing?
1. fget();
2. file_open();
3. fopen();
4. open_file();
13.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
14.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.
15.How do you pass a variable by value?
Just like in C++, put an ampersand in front of it, like $a = &$b
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment