how can compare two string in php
strcmp
<?php
echo strcmp("hello","hello");
?>
it will be display result:0
mysql order query
mysql order query
SELECT column_name(fieldname)
FROM table_name
ORDER BY column_name(fieldname) ASC|DESC
SELECT column_name(fieldname)
FROM table_name
ORDER BY column_name(fieldname) ASC|DESC
how can get current date in php
how can get current date in php
<?php
echo $date=date('d');
?>
it will display result current date
how can get current month in php
how can get current month in php
<?php
echo $date=date('m');
?>
it will display result current month
how can get current year in php
how can get current year in php
<?php
echo $date=date('Y');
?>
it will display result current year
<?php
echo $date=date('Y');
?>
it will display result current year
difference between __sleep and __wakeup in php
difference between __sleep and __wakeup in php
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
difference between array_search() and in_array() in php
difference between array_search() and in_array() in php
in_array() checks if the specified value exits in the array,whilearray_search() searches an array for a given value and returns the key
example of in_array():
<?
$a1=array("a"=>"one","b"=>"two");
if(in_array("one",$a1))
{
echo "exit";
}else
{
echo "not exist";
}
//example of array_search():
$a1=array("a"=>"one","b"=>"two");
echo array_search("one",$a1);
it returns: a
?>
in_array() checks if the specified value exits in the array,whilearray_search() searches an array for a given value and returns the key
example of in_array():
<?
$a1=array("a"=>"one","b"=>"two");
if(in_array("one",$a1))
{
echo "exit";
}else
{
echo "not exist";
}
//example of array_search():
$a1=array("a"=>"one","b"=>"two");
echo array_search("one",$a1);
it returns: a
?>
_sleep and _wakeup in php
_sleep and _wakeup in php
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.
how can upload file in php
how can upload file in php
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 .
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 .
persistent cookie in php
persistent cookie in php
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
A persistent cookie is a cookie which is stored in a cookie file permanently on the browser's computer. By default, cookies are created as temporary cookies which stored only in the browser's memory. When the browser is closed, temporary cookies will be erased. You should decide when to use temporary cookies and when to use persistent cookies based on their differences:
Temporary cookies can not be used for tracking long-term information.
Persistent cookies can be used for tracking long-term information.
Temporary cookies are safer because no programs other than the browser can access them.
Persistent cookies are less secure because users can open cookie files see the cookie values.
TYPES OF ERRORS IN PHP
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
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
differences between require and include, include_once
differences between require and include, include_once
: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.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:All three are used to an include file into the current page.If the file is not present, require(), calls a fatal error, while in include() does not.The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc
: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.
Anwser 2:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Anwser 3:All three are used to an include file into the current page.If the file is not present, require(), calls a fatal error, while in include() does not.The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. It des not call a fatal error if file not exists. require_once() does the same as include_once(), but it calls a fatal error if file not exists.
Anwser 4:File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc
Subscribe to:
Posts (Atom)