1.How can we know the number of days between two given dates using MySQL?
Ans: Use DATEDIFF()
SELECT DATEDIFF(NOW(),'2006-07-01');
2.How can we change the name of a column of a table?
Ans: This will change the name of column:
ALTER TABLE table_name CHANGE old_colm_name new_colm_name
3.What is the functionality of the function strstr and stristr?
Ans: 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.
4.What is the difference between ereg_replace() and eregi_replace()?
Ans: eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.
5.How can we submit a form without a submit button?
Ans: 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:
<a href=”javascript: document.myform.submit();”>Submit Me</a> Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.\nHow are you?\nThanks for visiting techpreparation’; print $str; ?>
Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters – \ and n
6.What’s the special meaning of __sleep and __wakeup?
Ans: __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them
7.How do you define a constant?
Ans: Via define() directive, like define ("MYCONSTANT", 100);
8.What are the differences between require and include, include_once?
Ans: require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
9.What is meant by urlencode and urldecode?
Ans: urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
10.How To Get the Uploaded File Information in the Receiving Script?
Ans: Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] - The Original file name on the browser system.
$_FILES[$fieldName]['type'] - The file type determined by the browser.
$_FILES[$fieldName]['size'] - The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] - The error code associated with this file upload.
The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>.
Ans: Use DATEDIFF()
SELECT DATEDIFF(NOW(),'2006-07-01');
2.How can we change the name of a column of a table?
Ans: This will change the name of column:
ALTER TABLE table_name CHANGE old_colm_name new_colm_name
3.What is the functionality of the function strstr and stristr?
Ans: 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.
4.What is the difference between ereg_replace() and eregi_replace()?
Ans: eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters.
5.How can we submit a form without a submit button?
Ans: 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:
<a href=”javascript: document.myform.submit();”>Submit Me</a> Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.\nHow are you?\nThanks for visiting techpreparation’; print $str; ?>
Because inside the single quotes the \n character is not interpreted as newline, just as a sequence of two characters – \ and n
6.What’s the special meaning of __sleep and __wakeup?
Ans: __sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them
7.How do you define a constant?
Ans: Via define() directive, like define ("MYCONSTANT", 100);
8.What are the differences between require and include, include_once?
Ans: require_once() and include_once() are both the functions to include and evaluate the specified file only once. If the specified file is included previous to the present call occurrence, it will not be done again.
But require() and include() will do it as many times they are asked to do.
9.What is meant by urlencode and urldecode?
Ans: urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25". URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
10.How To Get the Uploaded File Information in the Receiving Script?
Ans: Once the Web server received the uploaded file, it will call the PHP script specified in the form action attribute to process them. This receiving PHP script can get the uploaded file information through the predefined array called $_FILES. Uploaded file information is organized in $_FILES as a two-dimensional array as:
$_FILES[$fieldName]['name'] - The Original file name on the browser system.
$_FILES[$fieldName]['type'] - The file type determined by the browser.
$_FILES[$fieldName]['size'] - The Number of bytes of the file content.
$_FILES[$fieldName]['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES[$fieldName]['error'] - The error code associated with this file upload.
The $fieldName is the name used in the <INPUT TYPE=FILE, NAME=fieldName>.
Previous | Next |
:: Click the links below for similar type Questions and answers ::
0 comments:
Post a Comment