When assing an element of multidimensional array in PHP, such as:
$arr = array(array());
$idx = 0;
$arr['Key_1'][$idx] = $something;
indeed, there would be automatically generate another element in front:
$arr[0] = '';
As a result, there are two elements:
$arr[0] = '';
$arr['Key_1'][0] = 'something';
However, when keys do include [0], it would be no such issue. To fix up the problem, following code needs to be added before return the array:
unset($arr[0]);
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Fatal error: Call to undefined function... In PHP
First of all, the information contained in this error message is correct. The error was caused by the caller unable to access the called function, thus regarded as undefined function. There are several possibilities:
1. The function called is located in different PHP file, and it is not included or required by the caller file.
2. The php built-in function called has been deprecated.
3. Having an issue of encapsulation. It often happened when caller itself is not instantiated, and tried to call the function directly. Even if both caller and called are in same class, the PHP rule of encapsulation still applies. To fix up this, the called function must be declared as static, and the calling method need to be:
CalledClass::CalledFunction(); (Method 1)
If it is located in same class of the caller, it can be:
self::CalledFunction(); (Method 2)
When the caller is the object or instantiated of the class, it is necessary to use dynamic way, though it may be a public static function:
$result = $this->calledFunction(); (Method 3)
It would become more complicated when the caller is an function located within an instantiated object. In this case, method 3 does not work. Rather, Method 2 should be used.
Summary:
1. When caller is instantiated and externally called dynamically:
Called function declaration must be public.
Calling method: $instantiatedObject->calledFunction();
2. When caller is instantiated and externally called, and called function declared as static:
Called function declaration would be public static.
Calling method: $instantiatedObject->calledFunction();
3. When caller is not instantiated and externally called:
Called function declaration must be public static, or public when function is not within the class.
Calling method: $className::calledFunction(); or calledFunction(); when function is not within the class.
4. When caller is part of constructor and use dynamic method:
Called function declaration should be: private
Calling method: $this->calledFunction();
5. When caller is part of constructor and called function declared as static:
Called function declaration would be: private static
Calling method: $this->calledFunction();
This is not recommended.
6. When caller is internally located in another function, and called function declared as static:
Called function declaration should be: private static
Calling method: self::calledFunction();
There should be no other circumstances.
http://stackoverflow.com/questions/2220809/calling-a-method-from-another-method-in-same-php-class
1. The function called is located in different PHP file, and it is not included or required by the caller file.
2. The php built-in function called has been deprecated.
3. Having an issue of encapsulation. It often happened when caller itself is not instantiated, and tried to call the function directly. Even if both caller and called are in same class, the PHP rule of encapsulation still applies. To fix up this, the called function must be declared as static, and the calling method need to be:
CalledClass::CalledFunction(); (Method 1)
If it is located in same class of the caller, it can be:
self::CalledFunction(); (Method 2)
When the caller is the object or instantiated of the class, it is necessary to use dynamic way, though it may be a public static function:
$result = $this->calledFunction(); (Method 3)
It would become more complicated when the caller is an function located within an instantiated object. In this case, method 3 does not work. Rather, Method 2 should be used.
Summary:
1. When caller is instantiated and externally called dynamically:
Called function declaration must be public.
Calling method: $instantiatedObject->calledFunction();
2. When caller is instantiated and externally called, and called function declared as static:
Called function declaration would be public static.
Calling method: $instantiatedObject->calledFunction();
3. When caller is not instantiated and externally called:
Called function declaration must be public static, or public when function is not within the class.
Calling method: $className::calledFunction(); or calledFunction(); when function is not within the class.
4. When caller is part of constructor and use dynamic method:
Called function declaration should be: private
Calling method: $this->calledFunction();
5. When caller is part of constructor and called function declared as static:
Called function declaration would be: private static
Calling method: $this->calledFunction();
This is not recommended.
6. When caller is internally located in another function, and called function declared as static:
Called function declaration should be: private static
Calling method: self::calledFunction();
There should be no other circumstances.
http://stackoverflow.com/questions/2220809/calling-a-method-from-another-method-in-same-php-class
is_int() and is_string() Do Not Work As Expected In PHP
is_int() returns TRUE if the variable passed in is an integer, which may sound similar to is_numeric(). However, data passed in through a form or from MySQL query, even if numeric in content, is of type string, which means that is_int() will fail. Is_numeric(), on the other hand, returns true if the variable is a number or if it is a string containing a number also. This same problem applies to is_float(), as floating-point values set from user input are typed as strings. On contrast, when numeric data passed through a form or from MySQL query, is_string() does return TRUE.
This feature makes is_int() and is_string() next to useless.
http://www.tuxradar.com/practicalphp/7/7/3
This feature makes is_int() and is_string() next to useless.
http://www.tuxradar.com/practicalphp/7/7/3
Is_numeric() Is Not Good Enough in PHP
It supposes good enough. However, it fails in following circumstances:
1. In some machines number 0 returns false.
2. Unable to detect ‘+.1’ as numeric.
3. When number flagged as string in database, it returns true. Well, it is not in_numeric’s fault since it is designed that way.
4. However, when six digits number is hexadecimal number for color code in HTML, it would for sure stored in database as string, which does cause the problem.
Solutions:
For 1, If (is_numeric($para) || 0==$para))
For 2, no simple solution as good as enough
For 3, no solution
For 4, store hexadecimal number with # in front in database.
http://stackoverflow.com/questions/2774472/php-is-numeric-returns-false-on-0
1. In some machines number 0 returns false.
2. Unable to detect ‘+.1’ as numeric.
3. When number flagged as string in database, it returns true. Well, it is not in_numeric’s fault since it is designed that way.
4. However, when six digits number is hexadecimal number for color code in HTML, it would for sure stored in database as string, which does cause the problem.
Solutions:
For 1, If (is_numeric($para) || 0==$para))
For 2, no simple solution as good as enough
For 3, no solution
For 4, store hexadecimal number with # in front in database.
http://stackoverflow.com/questions/2774472/php-is-numeric-returns-false-on-0
Build an Uneven Nested Multidimentional Array in PHP
Build an uneven nested multidimensional array in PHP is very useful since you can retrieve the dataset mixed up by data from main table database and the affiliate tables, in which they are in primary and foreign key relationship. The beauty of it is you can retrieve it once for all and the data within the array maintain the same primary and foreign key relationship as they are in database. To append affiliate array into main array can use:
array_merge($mainArray, $affliateArray);
When declare the $affliateArray, it is better to give it a unique key, for instance 'appendix' below:
$affliateArray = array(array(array( "font_cd" => 'S'
, "font_color" => '000000'
)
)
);
$affliateArray['mainArrayDimension']['appendix'] = array( "font_cd" => $newCode
, "font_color" => $newColore
);
Sure, it would increase a dimension. However, it would clearly distinct the keys affiliate array from the keys in main array. Please note, it is preferred to use array_merge() than array_push() for easy maintain the main array's dimension.
The purpose of this rather complicated arrangement is not only one is able to preserve the primary and foreign key relationship in database, but also all child records in database, into a denormalized data structure in array.
http://www.java-samples.com/showtutorial.php?tutorialid=997
array_merge($mainArray, $affliateArray);
When declare the $affliateArray, it is better to give it a unique key, for instance 'appendix' below:
$affliateArray = array(array(array( "font_cd" => 'S'
, "font_color" => '000000'
)
)
);
$affliateArray['mainArrayDimension']['appendix'] = array( "font_cd" => $newCode
, "font_color" => $newColore
);
Sure, it would increase a dimension. However, it would clearly distinct the keys affiliate array from the keys in main array. Please note, it is preferred to use array_merge() than array_push() for easy maintain the main array's dimension.
The purpose of this rather complicated arrangement is not only one is able to preserve the primary and foreign key relationship in database, but also all child records in database, into a denormalized data structure in array.
http://www.java-samples.com/showtutorial.php?tutorialid=997
is_numeric() And is_int() in PHP
Both is_numeric() and is_int() will return neither TRUE nor FALSE, but null if parameter is null. Logically, it is correct. Practically, it does make these two functions next to useless. Because we human being would never believe null is numeric. For human being, it is obvious...
To make it useful, we would first consider if parameter is null or not, then if it is numeric. Here is simple way to test these three situations once for all:
if (0!=strlen(trim(@$para)) && is_numeric(@$para)) {...};
To make it useful, we would first consider if parameter is null or not, then if it is numeric. Here is simple way to test these three situations once for all:
if (0!=strlen(trim(@$para)) && is_numeric(@$para)) {...};
Trouble with Internet Explorer
The purpose of this article is to establish an uniform convention to deal with a very special issue of IE. It is for sure without this convention, websites would still run with or without problem. The issue is when IE passing null value from JavaScript to PHP, null value becomes string "null". If there is a possibility the user input could be "null", such as using "null" as login name or password, there is no way for PHP to detect which "null" is null and which "null" is input "null".
So, the accurate solution is never let JavaScript passing null to PHP, but using '' instead. It sounds easy; but JavaScript can generate null value without your knowledge. That is, if a parameter passing through a function to feed a form, when original parameter is undefined, eventually that undefined would be become string "null" or string "undefined" at the end of PHP. So, you would need to deal with every form input by special arrangement as follows:
; document.theForm.theInputItem.value = (parameter) ? parameter : ''
Then, to test if it is valid in JavaScript would be changed to:
; if (''!=parameter) {...}
At PHP end, it is relatively easy to detect if it is a valid input:
if (0!=strlen(trim(@$_POST["theInputItem"]))) {...};
However, for numeric data, it is not suitable to use '' instead null. It is still suggested to code as usual. The only difference is at PHP end:
if (0!=strlen(trim(@$_POST["theInputItem"])) && is_numeric(@$_POST["theInputItem"])) {...};
http://koncordpartners.blogspot.com/2009/12/test-various-nothings-in-php.html
So, the accurate solution is never let JavaScript passing null to PHP, but using '' instead. It sounds easy; but JavaScript can generate null value without your knowledge. That is, if a parameter passing through a function to feed a form, when original parameter is undefined, eventually that undefined would be become string "null" or string "undefined" at the end of PHP. So, you would need to deal with every form input by special arrangement as follows:
; document.theForm.theInputItem.value = (parameter) ? parameter : ''
Then, to test if it is valid in JavaScript would be changed to:
; if (''!=parameter) {...}
At PHP end, it is relatively easy to detect if it is a valid input:
if (0!=strlen(trim(@$_POST["theInputItem"]))) {...};
However, for numeric data, it is not suitable to use '' instead null. It is still suggested to code as usual. The only difference is at PHP end:
if (0!=strlen(trim(@$_POST["theInputItem"])) && is_numeric(@$_POST["theInputItem"])) {...};
http://koncordpartners.blogspot.com/2009/12/test-various-nothings-in-php.html
Passing JavaScript Array to PHP by Using POST
Passing JavaScript Array to Php is not very popular. However, in some circumstances it becomes necessary; for instance, passing value of a group of checkboxes, using array would be most suitable setting.
In general, passing array is same as passing a variable. In HTML part, it looks:
<input type="checkbox" name="jsArray[1]" value="firstValue">
<input type="checkbox" name="jsArray[2]" value="secondValue">
<input type="checkbox" name="jsArray[3]" value="thirdValue">
The problem happens when HTML codes are generated dynamically or the value of checkbox is assigned dynamically. Normal assignment method, namely document.formName.inputItemName.value = something does not work. There is a suggestion in http://www.it-base.ro/2007/07/27/send-a-javascript-array-to-php/.
Another simply solution is to use id to assign the value:
; document.getElementById('inputItemId').value = something
Easy.
In general, passing array is same as passing a variable. In HTML part, it looks:
<input type="checkbox" name="jsArray[1]" value="firstValue">
<input type="checkbox" name="jsArray[2]" value="secondValue">
<input type="checkbox" name="jsArray[3]" value="thirdValue">
The problem happens when HTML codes are generated dynamically or the value of checkbox is assigned dynamically. Normal assignment method, namely document.formName.inputItemName.value = something does not work. There is a suggestion in http://www.it-base.ro/2007/07/27/send-a-javascript-array-to-php/.
Another simply solution is to use id to assign the value:
; document.getElementById('inputItemId').value = something
Easy.
Convert PHP Array to JavaScript Array
<?php
////////////////////////////////////////////////////////////////////////////////////////////
// Universal function used to convert array in PHP to array in Javascript. //
// The result will be in string, includes declaration in Javascript, as well as the value //
// assigned to array in Javascript. //
// The array can be associative, as well as multidimensional, as many multidimensions as //
// you wish. This funcation is particularily useful when the number of elements and level //
// of multidimension is unknown. //
// Parameter $sJS is the string to represent the name of array in JS as you wish. //
////////////////////////////////////////////////////////////////////////////////////////////
function arrayToJavascript($aPHP, $aJS) // This is to deal with first level of recursion.
{
$lenFirst = @count($aPHP); // "@" deals with PHP Error Massage.
if (0!=$lenFirst && is_array($aPHP)) // Test if this is valid array or if reached the end of array.
{
echo "var ".$aJS." = new Array(".$lenFirst.");\n"; // Declare first level of array.
foreach ($aPHP as $key => &$value)
{
if (is_numeric($key))
{
$arrayString = $aJS."[".$key."]"; // Javascript variable.
}
else
{
$arrayString = $aJS."['".$key."']"; // Javascript variable.
};
toJSrecur($arrayString, $aPHP[$key]);
};
}
else
{
echo "Input is not a valid PHP array.";
};
}
function toJSrecur($arrayJS, $element) // This is to deal with standard level of recursion.
{ $len = @count($element); // count() does cause the trouble when reach the end of array.
if (0!=$len && is_array($element))
{
echo $arrayJS." = new Array(".$len.");\n"; // Declare each level of array.
foreach ($element as $key => &$value)
{
if (is_numeric($key))
{
$newString = $arrayJS."[".$key."]"; // Javascript variable.
}
else
{
$newString = $arrayJS."['".$key."']"; // String, is to be used by the echo at next level.
};
toJSrecur($newString, $element[$key]);
};
}
else // Start to write into javascript array at end of each branch in the recursion.
{
if ($element)
{
if (is_numeric($element))
{
$eleValue = $element;
}
else // Sign "'" in Javascript does cause trouble. Escape is needed.
{
$eleValue = "'".str_replace("'", "\'", $element)."'";
};
}
else
{
$eleValue = "''";
};
echo $arrayJS." = ".$eleValue.";\n"; // Assign values when the branch reached the end.
};
}
?>
////////////////////////////////////////////////////////////////////////////////////////////
// Universal function used to convert array in PHP to array in Javascript. //
// The result will be in string, includes declaration in Javascript, as well as the value //
// assigned to array in Javascript. //
// The array can be associative, as well as multidimensional, as many multidimensions as //
// you wish. This funcation is particularily useful when the number of elements and level //
// of multidimension is unknown. //
// Parameter $sJS is the string to represent the name of array in JS as you wish. //
////////////////////////////////////////////////////////////////////////////////////////////
function arrayToJavascript($aPHP, $aJS) // This is to deal with first level of recursion.
{
$lenFirst = @count($aPHP); // "@" deals with PHP Error Massage.
if (0!=$lenFirst && is_array($aPHP)) // Test if this is valid array or if reached the end of array.
{
echo "var ".$aJS." = new Array(".$lenFirst.");\n"; // Declare first level of array.
foreach ($aPHP as $key => &$value)
{
if (is_numeric($key))
{
$arrayString = $aJS."[".$key."]"; // Javascript variable.
}
else
{
$arrayString = $aJS."['".$key."']"; // Javascript variable.
};
toJSrecur($arrayString, $aPHP[$key]);
};
}
else
{
echo "Input is not a valid PHP array.";
};
}
function toJSrecur($arrayJS, $element) // This is to deal with standard level of recursion.
{ $len = @count($element); // count() does cause the trouble when reach the end of array.
if (0!=$len && is_array($element))
{
echo $arrayJS." = new Array(".$len.");\n"; // Declare each level of array.
foreach ($element as $key => &$value)
{
if (is_numeric($key))
{
$newString = $arrayJS."[".$key."]"; // Javascript variable.
}
else
{
$newString = $arrayJS."['".$key."']"; // String, is to be used by the echo at next level.
};
toJSrecur($newString, $element[$key]);
};
}
else // Start to write into javascript array at end of each branch in the recursion.
{
if ($element)
{
if (is_numeric($element))
{
$eleValue = $element;
}
else // Sign "'" in Javascript does cause trouble. Escape is needed.
{
$eleValue = "'".str_replace("'", "\'", $element)."'";
};
}
else
{
$eleValue = "''";
};
echo $arrayJS." = ".$eleValue.";\n"; // Assign values when the branch reached the end.
};
}
?>
mod_rewrite Tutorial
First to check if your mod_rewrite is enabled. Check phpinfo.php if you see mod_rewrite, it is enabled. If you do not see it, it is not necessary mean your server is not enabled. You may wish to go to following address to check further: http://www.wallpaperama.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html
Put it simple, mod_rewrite is just to find a matched string pattern in user’s input URL, and to replace it by the substitution string. So, the center of mod_rewrite is RewriteRule, which is responsible for the match and replace. The rest directives are just for setting purpose. The most used configuration directives other than RewriteRule are RewriteEngine, RewriteOptions.
RewriteEngine’s common value is:
On – This is because default value for this directive is off.
RewriteOptions’ common value is:
Inherit - This forces the current configuration to inherit the configuration of the parent.
RewriteRule’s syntax is:
RewriteRule Pattern Substitution [Flag]
Pattern needs to be bracketed by anchors ^youInputURL$. Pattern consists of two parts, the static substring you known already and those dynamic part. You do not need to change any for static substring, while you would need to group the dynamic part. The grouping can be done by bracket (). There are also two parts inside of (), first is the character class grouping by [], and second is the flag to tell whether the character class has only one character or nil, or more, etc. The character class is ruled by RegExp.
Following is the syntax for the pattern:
(text) - Grouping of text
[chars] - Character class: One of chars
[^chars] - Character class: None of chars
text1|text2 - Alternative: text1 or text2
? - 0 or 1 character of the preceding text
* - 0 or N character of the preceding text
. - 1 character of the preceding text
+ - 1 or N character of the preceding text
\char - escape that particular char, for instance to specify the chars ".[]()" etc.
The substitution consists of two parts, the static string and the dynamic part as grouped in preceding pattern. The second is always shown as $1.
Flag’s syntax is [SOMETHING, SOMETHING, SOMETHING]. SOMETHING is the flag. Following are common used flags:
NC - This makes the input pattern case-insensitive.
L - Stop the rewriting process here and don't apply any more rewriting rules. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules.
Example:
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^([A-Za-z0-9-]+)$ /php/main.php?uname=$1 [NC,L]
http://corz.org/serv/tricks/htaccess2.php
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
Put it simple, mod_rewrite is just to find a matched string pattern in user’s input URL, and to replace it by the substitution string. So, the center of mod_rewrite is RewriteRule, which is responsible for the match and replace. The rest directives are just for setting purpose. The most used configuration directives other than RewriteRule are RewriteEngine, RewriteOptions.
RewriteEngine’s common value is:
On – This is because default value for this directive is off.
RewriteOptions’ common value is:
Inherit - This forces the current configuration to inherit the configuration of the parent.
RewriteRule’s syntax is:
RewriteRule Pattern Substitution [Flag]
Pattern needs to be bracketed by anchors ^youInputURL$. Pattern consists of two parts, the static substring you known already and those dynamic part. You do not need to change any for static substring, while you would need to group the dynamic part. The grouping can be done by bracket (). There are also two parts inside of (), first is the character class grouping by [], and second is the flag to tell whether the character class has only one character or nil, or more, etc. The character class is ruled by RegExp.
Following is the syntax for the pattern:
(text) - Grouping of text
[chars] - Character class: One of chars
[^chars] - Character class: None of chars
text1|text2 - Alternative: text1 or text2
? - 0 or 1 character of the preceding text
* - 0 or N character of the preceding text
. - 1 character of the preceding text
+ - 1 or N character of the preceding text
\char - escape that particular char, for instance to specify the chars ".[]()" etc.
The substitution consists of two parts, the static string and the dynamic part as grouped in preceding pattern. The second is always shown as $1.
Flag’s syntax is [SOMETHING, SOMETHING, SOMETHING]. SOMETHING is the flag. Following are common used flags:
NC - This makes the input pattern case-insensitive.
L - Stop the rewriting process here and don't apply any more rewriting rules. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules.
Example:
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^([A-Za-z0-9-]+)$ /php/main.php?uname=$1 [NC,L]
http://corz.org/serv/tricks/htaccess2.php
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
Code Conventions: JavaScript
Organizing
There can be six major parts:
1. Passing Variable Register: This is to register any variable across the HTML files. Do not use crossing file variable directly in body of JavaScript, instead declare here. For instance:
; var localVar = parent.superVar
2. Passing Function Register: To register the functions calling other functions located in different HTML file. Do not call crossing file function directly in body of JavaScript, instead declare here. For instance:
; function closeProcess()
{
; parent.closing()
}
Put Passing Variable Register and Passing Function Register at top of JavaScript file to enable easier updating during coding phrase.
3. Local Global Variable Declaration.
4. Event Functions: Include all event functions here, such as onload, etc.
5. HTML Action Functions: If the function is called by HTML file, initialized by the user, it should be included here.
6. Internally Called Functions: Functions called by event functions or action functions.
End of Statement
JavaScript allows the developer to decide whether or not to end a line with a semicolon. If the semicolon is not provided, JavaScript considers the end of the line as the end of the statement. It is suggested to use semicolon instead of nature line break. Furthermore, you can indeed use semicolon in front of each statement, not only emphasis the line break, but also to increase visual impact on the indentation. All examples in this post are in this format.
Comments
It is suggested to use closed comments tag as much as possible: <!-- -->. By doing this, it would be relatively easier to keep coding parts clearer. In addition, if you are using PHP Wrapping JavaScript Debugging Method, as introduced here:
http://koncordpartners.blogspot.com/2010/04/how-to-enforce-download-of-javascript.html, it is essential to use the closed comments.
DHTML
Use + to concatenate every line of HTML codes, such as:
; var htmlBody = ''
+ ' <table> ...
+ ' <tr> ...
Whitespace within string serves no purpose for HTML. However, it can make visual alignment for coding purpose.
Function Declaration
Always use most orthdox variablized function declaration:
; funcation func()
{
...
}
Avoid to use variablized function declaration like var func = function() {...}, unless it is necessary. If you do use variablized function declaration, make sure it had been placed before the caller. For details please see http://koncordpartners.blogspot.com/2010/04/function-declaration-in-javascript.html.
Form With PHP Behind
Use '' instead of null. Accordingly, the PHP end should be:
if (0!=strlen(trim(@$_POST["theInputItem"]))) {...};
When use function to assign value to form, string parameter would need to be assigned with '' in consideration of it might be null or undefined:
; document.theForm.theInputItem.value = (parameter) ? parameter : ''
For details, please refer to http://koncordpartners.blogspot.com/2010/04/trouble-with-internet-explorer.html.
http://javascript.crockford.com/code.html
There can be six major parts:
1. Passing Variable Register: This is to register any variable across the HTML files. Do not use crossing file variable directly in body of JavaScript, instead declare here. For instance:
; var localVar = parent.superVar
2. Passing Function Register: To register the functions calling other functions located in different HTML file. Do not call crossing file function directly in body of JavaScript, instead declare here. For instance:
; function closeProcess()
{
; parent.closing()
}
Put Passing Variable Register and Passing Function Register at top of JavaScript file to enable easier updating during coding phrase.
3. Local Global Variable Declaration.
4. Event Functions: Include all event functions here, such as onload, etc.
5. HTML Action Functions: If the function is called by HTML file, initialized by the user, it should be included here.
6. Internally Called Functions: Functions called by event functions or action functions.
End of Statement
JavaScript allows the developer to decide whether or not to end a line with a semicolon. If the semicolon is not provided, JavaScript considers the end of the line as the end of the statement. It is suggested to use semicolon instead of nature line break. Furthermore, you can indeed use semicolon in front of each statement, not only emphasis the line break, but also to increase visual impact on the indentation. All examples in this post are in this format.
Comments
It is suggested to use closed comments tag as much as possible: <!-- -->. By doing this, it would be relatively easier to keep coding parts clearer. In addition, if you are using PHP Wrapping JavaScript Debugging Method, as introduced here:
http://koncordpartners.blogspot.com/2010/04/how-to-enforce-download-of-javascript.html, it is essential to use the closed comments.
DHTML
Use + to concatenate every line of HTML codes, such as:
; var htmlBody = ''
+ ' <table> ...
+ ' <tr> ...
Whitespace within string serves no purpose for HTML. However, it can make visual alignment for coding purpose.
Function Declaration
Always use most orthdox variablized function declaration:
; funcation func()
{
...
}
Avoid to use variablized function declaration like var func = function() {...}, unless it is necessary. If you do use variablized function declaration, make sure it had been placed before the caller. For details please see http://koncordpartners.blogspot.com/2010/04/function-declaration-in-javascript.html.
Form With PHP Behind
Use '' instead of null. Accordingly, the PHP end should be:
if (0!=strlen(trim(@$_POST["theInputItem"]))) {...};
When use function to assign value to form, string parameter would need to be assigned with '' in consideration of it might be null or undefined:
; document.theForm.theInputItem.value = (parameter) ? parameter : ''
For details, please refer to http://koncordpartners.blogspot.com/2010/04/trouble-with-internet-explorer.html.
http://javascript.crockford.com/code.html
Heredoc and Nowdoc in PHP
Heredoc is to double-quoted string. So the inside can be parsed if there is variable. There is bug associated with Heredoc, namely the line with the closing identifier must contain no other characters, except possibly a semicolon (;). Example:
$err = ‘Parse error, unexpected $end in this.php on line xx’;
<<<HEREDOC
This is to show error message “$err” if you put whitespace either at front or end of closing line.
HEREDOC
Nowdocs are to single-quoted strings however. So a nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. This is very useful to parse a large block of embedded dynamic codes. Example:
<<<’NOWDOC’
Within this block, though $err is a variable, the final result would be exactly same as what you are seeing now. The variable “$err” won’t be parsed.
NOWDOC
No escape needed for both methods.
In addition, although you can use any word for heredoc and nowdoc purpose, it is recommended using exactly these words to emphasis the difference as well as the help you to remember what these techniques are called.
http://ca2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
$err = ‘Parse error, unexpected $end in this.php on line xx’;
<<<HEREDOC
This is to show error message “$err” if you put whitespace either at front or end of closing line.
HEREDOC
Nowdocs are to single-quoted strings however. So a nowdoc is specified similarly to a heredoc, but no parsing is done inside a nowdoc. This is very useful to parse a large block of embedded dynamic codes. Example:
<<<’NOWDOC’
Within this block, though $err is a variable, the final result would be exactly same as what you are seeing now. The variable “$err” won’t be parsed.
NOWDOC
No escape needed for both methods.
In addition, although you can use any word for heredoc and nowdoc purpose, it is recommended using exactly these words to emphasis the difference as well as the help you to remember what these techniques are called.
http://ca2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
What Happened If Your PHP Not Showing?
If PHP was not enabled, your .php file will be treated as .html file. So, <?php…> will be treated as html tag, which would not show at all. More tricky is, if your codes include ->, the first > will be treated as the end tag for <?php…>. This would confuse you because you would think the first -> has been mistakenly regarded as ?>.
Here are solutions. First, save as following piece of codes as phpinfo.php:
<?php
phpinfo();
?>
Then call it in your browser. It will list all of the configuration information about php. If it shows a blank page, it means your php has not been enabled.
If you are in personal server, run following scripts:
LoadModule php5_module "/path/to/php5apache2_2.dll" #use php5apache2.dll for apache 2.x, use php5apache.dll for apache1.x
AddType application/x-httpd-php .php
If you are in shared server, contact administrator.
The another possibility is your server does not recognize your php codes if they were composited by text editor such as Notepad, which indeed still have some uncleared characters. To overcome this, find a pure cleaning php code editor, such as Crimson Editor, copy to it and save as new .php file.
Here are solutions. First, save as following piece of codes as phpinfo.php:
<?php
phpinfo();
?>
Then call it in your browser. It will list all of the configuration information about php. If it shows a blank page, it means your php has not been enabled.
If you are in personal server, run following scripts:
LoadModule php5_module "/path/to/php5apache2_2.dll" #use php5apache2.dll for apache 2.x, use php5apache.dll for apache1.x
AddType application/x-httpd-php .php
If you are in shared server, contact administrator.
The another possibility is your server does not recognize your php codes if they were composited by text editor such as Notepad, which indeed still have some uncleared characters. To overcome this, find a pure cleaning php code editor, such as Crimson Editor, copy to it and save as new .php file.
A New Sorting Mechanism in Database
If one wants to add a field to record sorting order, following mechanism is recommended.
In HTML’s Select List or Option List, the positioning indication can be written as:
Before Item 1 – Order_Value is 0
Before Item 2 – Order_Value is 1
Then, the Sort_Order can be written into Database as Order_Value*2-1, which can be applied in both cases as new record or move existing record. By doing this, one can easily insert or move item. This is because in database this field is recorded as 0, 2, 4, 6... Of course, inserting or moving can be done once a time, followed by sorting.
Following is the example in PHP.
public function saveCateNew($order)
{ $orderNew = $order*2-1;
$query = sprintf( ' INSERT INTO CATES_SELF '
. ' (TITLE_1 '
. ' , SORT_ORDER '
. ' ) VALUES '
. ' ("%s" '
. ' , %d '
. ' ) '
, mysql_real_escape_string($this->title_1, $GLOBALS['DB'])
, $orderNew
);
mysql_query($query, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$this->sortCate();
}
public function saveCateOld($order)
{ $orderNew = $order*2-1;
$query = sprintf( ' UPDATE CATES_SELF '
. ' SET TITLE_1 = "%s" '
. ' , SORT_ORDER = %d '
. ' WHERE ID_CATESELF = %d '
, mysql_real_escape_string($this->title_1, $GLOBALS['DB'])
, $orderNew
, $this->id_cateself
);
mysql_query($query, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$this->sortCate();
}
function sortCate()
{ $query = sprintf( ' SELECT ID_CATESELF '
. ' FROM CATES_SELF '
. ' ORDER BY SORT_ORDER '
);
$result = mysql_query($query, $GLOBALS['DB']);
$index = 0;
while($row = mysql_fetch_assoc($result))
{ $id = $row['ID_CATESELF'];
$queryInner = sprintf( ' UPDATE CATES_SELF '
. ' SET SORT_ORDER = %d '
. ' WHERE ID_CATESELF = %d '
, $index
, $id
);
mysql_query($queryInner, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$index = $index+2;
};
mysql_free_result($result);
}
In HTML’s Select List or Option List, the positioning indication can be written as:
Before Item 1 – Order_Value is 0
Before Item 2 – Order_Value is 1
Then, the Sort_Order can be written into Database as Order_Value*2-1, which can be applied in both cases as new record or move existing record. By doing this, one can easily insert or move item. This is because in database this field is recorded as 0, 2, 4, 6... Of course, inserting or moving can be done once a time, followed by sorting.
Following is the example in PHP.
public function saveCateNew($order)
{ $orderNew = $order*2-1;
$query = sprintf( ' INSERT INTO CATES_SELF '
. ' (TITLE_1 '
. ' , SORT_ORDER '
. ' ) VALUES '
. ' ("%s" '
. ' , %d '
. ' ) '
, mysql_real_escape_string($this->title_1, $GLOBALS['DB'])
, $orderNew
);
mysql_query($query, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$this->sortCate();
}
public function saveCateOld($order)
{ $orderNew = $order*2-1;
$query = sprintf( ' UPDATE CATES_SELF '
. ' SET TITLE_1 = "%s" '
. ' , SORT_ORDER = %d '
. ' WHERE ID_CATESELF = %d '
, mysql_real_escape_string($this->title_1, $GLOBALS['DB'])
, $orderNew
, $this->id_cateself
);
mysql_query($query, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$this->sortCate();
}
function sortCate()
{ $query = sprintf( ' SELECT ID_CATESELF '
. ' FROM CATES_SELF '
. ' ORDER BY SORT_ORDER '
);
$result = mysql_query($query, $GLOBALS['DB']);
$index = 0;
while($row = mysql_fetch_assoc($result))
{ $id = $row['ID_CATESELF'];
$queryInner = sprintf( ' UPDATE CATES_SELF '
. ' SET SORT_ORDER = %d '
. ' WHERE ID_CATESELF = %d '
, $index
, $id
);
mysql_query($queryInner, $GLOBALS['DB']) or die("An error has ocured: ".mysql_error().":".mysql_errno());
$index = $index+2;
};
mysql_free_result($result);
}
Option List in HTML
Code in HTML:
‹form id="oForm" name="oForm" action="" method="POST"›
‹select id="sList" name="sList" onchange="picking(this.form.cateList)"›
‹/select›
‹/form›
Script in JavaScript:
; var position
; var len
; window.onload = function()
{ ; len = selfCate.length
; for (var i=0; i ; createOption('cateForm', 'cateList', len, 'At the end')
; document.cateForm.cateList[len].selected = true
; position = len
}
; function picking(dropDown)
{ ; var myIndex = dropDown.selectedIndex
; position = dropDown.options[myIndex].value
}
; function createOption(formName, selectName, indexValue, newText)
{ ; var objSelect = document.forms[formName].elements[selectName]
; var objOption = document.createElement("option")
; objOption.value = indexValue
; objOption.text = newText
; if(document.all && !(window.opera)) objSelect.add(objOption)
else objSelect.add(objOption, null)
}
; function removeOptions(selectId, firstNumToKeep, lastNumTokeep)
{ ; var elSel = document.getElementById(selectId)
; var total = elSel.length - lastNumTokeep - 1
; for (var i=total; i>=firstNumToKeep; i--) elSel.remove(i)
}
Special Notes:
1. In window.onload, “document.cateForm.cateList[len].selected = true” is to show what item is preselected in HTML. It is “position = len” to tell PHP what was preselected, if preselected has not been changed.
2. In picking(), apart of the need of global variable, the writing of var position = dropDown.options[myIndex].value is not recommended because some browser request variable declaration and assignment being separated.
‹form id="oForm" name="oForm" action="" method="POST"›
‹select id="sList" name="sList" onchange="picking(this.form.cateList)"›
‹/select›
‹/form›
Script in JavaScript:
; var position
; var len
; window.onload = function()
{ ; len = selfCate.length
; for (var i=0; i
; document.cateForm.cateList[len].selected = true
; position = len
}
; function picking(dropDown)
{ ; var myIndex = dropDown.selectedIndex
; position = dropDown.options[myIndex].value
}
; function createOption(formName, selectName, indexValue, newText)
{ ; var objSelect = document.forms[formName].elements[selectName]
; var objOption = document.createElement("option")
; objOption.value = indexValue
; objOption.text = newText
; if(document.all && !(window.opera)) objSelect.add(objOption)
else objSelect.add(objOption, null)
}
; function removeOptions(selectId, firstNumToKeep, lastNumTokeep)
{ ; var elSel = document.getElementById(selectId)
; var total = elSel.length - lastNumTokeep - 1
; for (var i=total; i>=firstNumToKeep; i--) elSel.remove(i)
}
Special Notes:
1. In window.onload, “document.cateForm.cateList[len].selected = true” is to show what item is preselected in HTML. It is “position = len” to tell PHP what was preselected, if preselected has not been changed.
2. In picking(), apart of the need of global variable, the writing of var position = dropDown.options[myIndex].value is not recommended because some browser request variable declaration and assignment being separated.
Multiple Forms in HTML
If there are more than one form in HTML, give every input item a global unique id and name. Else, PHP won’t be able to pick up right item, although you might put input item in right order in HTML.
Unicode Like Chinese Japanese Korean Characters In and Out MySQL Through PHP & Java
Both MySQL and PHP/Java support the Unicode, namely UTF-8. To be able to store into and retrieve these Unicode characters in MySQL database, one would need to do following things:
MySQL needs to be informed through PHP/Java. So, following code needs to be placed just after the connection. If the connection is centralized, this code is better to be in that centralized file:
PHP: mysql_query("SET NAMES 'UTF8'");
Java: stmt.execute("SET NAMES 'utf8'");
For all your PHP files generates HTML scripts, please include following code at top of the file:
header("Content-Type: text/html; charset=UTF-8");
For all your HTML files, following script is needed in the head of HTML:
‹ meta http-equiv="Content-Type" content="text/html; charset=UTF-8" ›
Done. Please note, in first piece of PHP code, it is UTF8 and in second PHP code and last HTML script it is UTF-8. Else, it won’t work properly.
If your codes include any of following piece, simply remove it:
PHP: mysql_query("SET CHARACTER SET 'UTF8'");
Java: stmt.execute("SET CHARACTER SET 'utf8'");
MySQL needs to be informed through PHP/Java. So, following code needs to be placed just after the connection. If the connection is centralized, this code is better to be in that centralized file:
PHP: mysql_query("SET NAMES 'UTF8'");
Java: stmt.execute("SET NAMES 'utf8'");
For all your PHP files generates HTML scripts, please include following code at top of the file:
header("Content-Type: text/html; charset=UTF-8");
For all your HTML files, following script is needed in the head of HTML:
‹ meta http-equiv="Content-Type" content="text/html; charset=UTF-8" ›
Done. Please note, in first piece of PHP code, it is UTF8 and in second PHP code and last HTML script it is UTF-8. Else, it won’t work properly.
If your codes include any of following piece, simply remove it:
PHP: mysql_query("SET CHARACTER SET 'UTF8'");
Java: stmt.execute("SET CHARACTER SET 'utf8'");
Number of Elements of Array
Number of elements of array is very usual, which can be used as control for the loop or other purposes. Function to get it in JavaScript is varArray.length. In PHP it is count($ varArray) or sizeof($ varArray). Since sizeof() is just an alias of count(), it is suggested using count(), since sizeof() has other meaning in other languages.
The problem happens when array is undefined/not exist. In JavaScript .length would generate a fatal error. So, for save play, it is suggested always using follow codes:
var len = 0;
if ('undefined'!=typeof(varArray)) len = varArray.length;
In PHP count() would generate a return value of 0 together with a non-fatal error message, which would cause even more serious problem because of its non-fatal nature. Fortunately, PHP provides an easy non-fatal error message suppress method “@”:
@count($varArray);
It is very useful because it enables you to always associate @ with count(). And please do so.
For multidimensional array, the usage will be exactly same; and can be used for particular dimension, such as varArray[i] or $varArray[i].
The problem happens when array is undefined/not exist. In JavaScript .length would generate a fatal error. So, for save play, it is suggested always using follow codes:
var len = 0;
if ('undefined'!=typeof(varArray)) len = varArray.length;
In PHP count() would generate a return value of 0 together with a non-fatal error message, which would cause even more serious problem because of its non-fatal nature. Fortunately, PHP provides an easy non-fatal error message suppress method “@”:
@count($varArray);
It is very useful because it enables you to always associate @ with count(). And please do so.
For multidimensional array, the usage will be exactly same; and can be used for particular dimension, such as varArray[i] or $varArray[i].
Test Various “Nothings” in PHP
Following php codes is to test six different “nothing”variables together with popular functions, plus number 1 as control.
‹?php
$undefinedVar;
$nullVar = null;
$strEmpty = "";
$strChanged = "initial value";
$numZero = 0;
$numChanged = 1;
$numOne = 1;
$strChanged = null;
$numChanged = null;
echo "‹br/›11. undefinedVar: (".$undefinedVar.")";
echo "‹br/›12. nullVar: (".$nullVar.")";
echo "‹br/›13. strEmpty: (".$strEmpty.")";
echo "‹br/›14. strChanged: (".$strChanged.")";
echo "‹br/›15. numZero: (".$numZero.")";
echo "‹br/›16. numChanged: (".$numChanged.")";
echo "‹br/›21. is_null-undefinedVar: (".is_null($undefinedVar).")";
echo "‹br/›22. is_null-nullVar: (".is_null($nullVar).")";
echo "‹br/›23. is_null-strEmpty: (".is_null($strEmpty).")";
echo "‹br/›24. is_null-strChanged: (".is_null($strChanged).")";
echo "‹br/›25. is_null-numZero: (".is_null($numZero).")";
echo "‹br/›26. is_null-numChanged: (".is_null($numChanged).")";
echo "‹br/›31. isset-undefinedVar: (".isset($undefinedVar).")";
echo "‹br/›32. isset-nullVar: (".isset($nullVar).")";
echo "‹br/›33. isset-strEmpty: (".isset($strEmpty).")";
echo "‹br/›34. isset-strChanged: (".isset($strChanged).")";
echo "‹br/›35. isset-numZero: (".isset($numZero).")";
echo "‹br/›36. isset-numChanged: (".isset($numChanged).")";
echo "‹br/›47. TRUE: (".TRUE.")";
echo "‹br/›48. FALSE: (".FALSE.")";
echo "‹br/›51. empty-undefinedVar: (".empty($undefinedVar).")";
echo "‹br/›52. empty-nullVar: (".empty($nullVar).")";
echo "‹br/›53. empty-strEmpty: (".empty($strEmpty).")";
echo "‹br/›54. empty-strChanged: (".empty($strChanged).")";
echo "‹br/›55. empty-numZero: (".empty($numZero).")";
echo "‹br/›56. empty-numChanged: (".empty($numChanged).")";
echo "‹br/›57. empty-numOne: (".empty($numOne).")";
echo "‹br/›61. defined-undefinedVar: (".defined($undefinedVar).")";
echo "‹br/›62. defined-nullVar: (".defined($nullVar).")";
echo "‹br/›63. defined-strEmpty: (".defined($strEmpty).")";
echo "‹br/›64. defined-strChanged: (".defined($strChanged).")";
echo "‹br/›65. defined-numZero: (".defined($numZero).")";
echo "‹br/›66. defined-numChanged: (".defined($numChanged).")";
echo "‹br/›71. strlen-trim-undefinedVar: (".strlen(trim($undefinedVar)).")";
echo "‹br/›72. strlen-trim-nullVar: (".strlen(trim($nullVar)).")";
echo "‹br/›73. strlen-trim-strEmpty: (".strlen(trim($strEmpty)).")";
echo "‹br/›74. strlen-trim-strChanged: (".strlen(trim($strChanged)).")";
echo "‹br/›75. strlen-trim-numZero: (".strlen(trim($numZero)).")";
echo "‹br/›76. strlen-trim-numChanged: (".strlen(trim($numChanged)).")";
?›
unset() does not work for any one of them. Therefore, it had been excluded.
Test results in both Firefox and IE are identical, as follows:
11. undefinedVar: ()
12. nullVar: ()
13. strEmpty: ()
14. strChanged: ()
15. numZero: (0)
16. numChanged: ()
21. is_null-undefinedVar: (1)
22. is_null-nullVar: (1)
23. is_null-strEmpty: ()
24. is_null-strChanged: (1)
25. is_null-numZero: ()
26. is_null-numChanged: (1)
31. isset-undefinedVar: ()
32. isset-nullVar: ()
33. isset-strEmpty: (1)
34. isset-strChanged: ()
35. isset-numZero: (1)
36. isset-numChanged: ()
47. TRUE: (1)
48. FALSE: ()
51. empty-undefinedVar: (1)
52. empty-nullVar: (1)
53. empty-strEmpty: (1)
54. empty-strChanged: (1)
55. empty-numZero: (1)
56. empty-numChanged: (1)
57. empty-numOne: ()
61. defined-undefinedVar: ()
62. defined-nullVar: ()
63. defined-strEmpty: ()
64. defined-strChanged: ()
65. defined-numZero: ()
66. defined-numChanged: ()
71. strlen-trim-undefinedVar: (0)
72. strlen-trim-nullVar: (0)
73. strlen-trim-strEmpty: (0)
74. strlen-trim-strChanged: (0)
75. strlen-trim-numZero: (1)
76. strlen-trim-numChanged: (0)
Observed, included but not limited to this test:
1. Results in Firefox and IE are exactly same. However, if an null variable passed from JavaScript to PHP, in IE, it would be shown as a string "null". In a real case scenario, a variable is to pass from form feeding in HTML/JavaScript to PHP. However, it had only be assigned with value “null”. It supposes an integer data type. Unfortunately, in is_null() in PHP, it results not null, while echo shows “null” in IE and nothing in Firefox.
2. unset() does not work at all for all of them.
3. is_null() works fine. It however regards empty string as not null, which should be.
4. isset() works fine. It regards empty string as set.
5. is_null() is just opposite to isset().
6. empty() works for all, including regarding number 0 as empty.
7. defined() is to detect if a constant string exists, which does works fine here, since no constant string here.
8. strlen(trim()) does work fine except number 0, which should be.
Conclusion:
First of all, never use null in JavaScript where it supposed to be a string. Use '' instead. This is because in IE, when JavaScript passes string to PHP, null would become 'null'.
1. If one want to include everything, null, empty string, number 0, and even string “0”, the best approach is to use if(empty($var)).
2. If one wants to include null and empty string and exclude number 0, if(0==strlen(trim($var)) might be best approach. However, this approach is unable to detect the string "null".
3. If one wants to include null and number 0 and exclude empty string, the best approach maybe if(is_null($var) || 0==$var).
4. If one wants to only include null and exclude empty string and number 0, the best approach is if(is_null($var)). However, since both JavaScript and PHP does not tell the data type when declare a variable, it somehow easily to be mixed up the undefined variable or null variable with empty string. It is therefore suggested extra caution shall be applied to exclude empty string.
5. In most case people dealing with null would include undefined variable, null variable, empty string in JavaScript and PHP. For special case mentioned above for IE, it would includes string "null" as well, which isn't covered by Conclustion 2. So, the possible most save approach is put two together:
if(0==strlen(trim($var)) || "null"==$var)
6. To deal with undefined array, please refer to http://koncordpartners.blogspot.com/2009/12/number-of-elements-of-array.html.
http://ca2.php.net/manual/en/function.empty.php
‹?php
$undefinedVar;
$nullVar = null;
$strEmpty = "";
$strChanged = "initial value";
$numZero = 0;
$numChanged = 1;
$numOne = 1;
$strChanged = null;
$numChanged = null;
echo "‹br/›11. undefinedVar: (".$undefinedVar.")";
echo "‹br/›12. nullVar: (".$nullVar.")";
echo "‹br/›13. strEmpty: (".$strEmpty.")";
echo "‹br/›14. strChanged: (".$strChanged.")";
echo "‹br/›15. numZero: (".$numZero.")";
echo "‹br/›16. numChanged: (".$numChanged.")";
echo "‹br/›21. is_null-undefinedVar: (".is_null($undefinedVar).")";
echo "‹br/›22. is_null-nullVar: (".is_null($nullVar).")";
echo "‹br/›23. is_null-strEmpty: (".is_null($strEmpty).")";
echo "‹br/›24. is_null-strChanged: (".is_null($strChanged).")";
echo "‹br/›25. is_null-numZero: (".is_null($numZero).")";
echo "‹br/›26. is_null-numChanged: (".is_null($numChanged).")";
echo "‹br/›31. isset-undefinedVar: (".isset($undefinedVar).")";
echo "‹br/›32. isset-nullVar: (".isset($nullVar).")";
echo "‹br/›33. isset-strEmpty: (".isset($strEmpty).")";
echo "‹br/›34. isset-strChanged: (".isset($strChanged).")";
echo "‹br/›35. isset-numZero: (".isset($numZero).")";
echo "‹br/›36. isset-numChanged: (".isset($numChanged).")";
echo "‹br/›47. TRUE: (".TRUE.")";
echo "‹br/›48. FALSE: (".FALSE.")";
echo "‹br/›51. empty-undefinedVar: (".empty($undefinedVar).")";
echo "‹br/›52. empty-nullVar: (".empty($nullVar).")";
echo "‹br/›53. empty-strEmpty: (".empty($strEmpty).")";
echo "‹br/›54. empty-strChanged: (".empty($strChanged).")";
echo "‹br/›55. empty-numZero: (".empty($numZero).")";
echo "‹br/›56. empty-numChanged: (".empty($numChanged).")";
echo "‹br/›57. empty-numOne: (".empty($numOne).")";
echo "‹br/›61. defined-undefinedVar: (".defined($undefinedVar).")";
echo "‹br/›62. defined-nullVar: (".defined($nullVar).")";
echo "‹br/›63. defined-strEmpty: (".defined($strEmpty).")";
echo "‹br/›64. defined-strChanged: (".defined($strChanged).")";
echo "‹br/›65. defined-numZero: (".defined($numZero).")";
echo "‹br/›66. defined-numChanged: (".defined($numChanged).")";
echo "‹br/›71. strlen-trim-undefinedVar: (".strlen(trim($undefinedVar)).")";
echo "‹br/›72. strlen-trim-nullVar: (".strlen(trim($nullVar)).")";
echo "‹br/›73. strlen-trim-strEmpty: (".strlen(trim($strEmpty)).")";
echo "‹br/›74. strlen-trim-strChanged: (".strlen(trim($strChanged)).")";
echo "‹br/›75. strlen-trim-numZero: (".strlen(trim($numZero)).")";
echo "‹br/›76. strlen-trim-numChanged: (".strlen(trim($numChanged)).")";
?›
unset() does not work for any one of them. Therefore, it had been excluded.
Test results in both Firefox and IE are identical, as follows:
11. undefinedVar: ()
12. nullVar: ()
13. strEmpty: ()
14. strChanged: ()
15. numZero: (0)
16. numChanged: ()
21. is_null-undefinedVar: (1)
22. is_null-nullVar: (1)
23. is_null-strEmpty: ()
24. is_null-strChanged: (1)
25. is_null-numZero: ()
26. is_null-numChanged: (1)
31. isset-undefinedVar: ()
32. isset-nullVar: ()
33. isset-strEmpty: (1)
34. isset-strChanged: ()
35. isset-numZero: (1)
36. isset-numChanged: ()
47. TRUE: (1)
48. FALSE: ()
51. empty-undefinedVar: (1)
52. empty-nullVar: (1)
53. empty-strEmpty: (1)
54. empty-strChanged: (1)
55. empty-numZero: (1)
56. empty-numChanged: (1)
57. empty-numOne: ()
61. defined-undefinedVar: ()
62. defined-nullVar: ()
63. defined-strEmpty: ()
64. defined-strChanged: ()
65. defined-numZero: ()
66. defined-numChanged: ()
71. strlen-trim-undefinedVar: (0)
72. strlen-trim-nullVar: (0)
73. strlen-trim-strEmpty: (0)
74. strlen-trim-strChanged: (0)
75. strlen-trim-numZero: (1)
76. strlen-trim-numChanged: (0)
Observed, included but not limited to this test:
1. Results in Firefox and IE are exactly same. However, if an null variable passed from JavaScript to PHP, in IE, it would be shown as a string "null". In a real case scenario, a variable is to pass from form feeding in HTML/JavaScript to PHP. However, it had only be assigned with value “null”. It supposes an integer data type. Unfortunately, in is_null() in PHP, it results not null, while echo shows “null” in IE and nothing in Firefox.
2. unset() does not work at all for all of them.
3. is_null() works fine. It however regards empty string as not null, which should be.
4. isset() works fine. It regards empty string as set.
5. is_null() is just opposite to isset().
6. empty() works for all, including regarding number 0 as empty.
7. defined() is to detect if a constant string exists, which does works fine here, since no constant string here.
8. strlen(trim()) does work fine except number 0, which should be.
Conclusion:
First of all, never use null in JavaScript where it supposed to be a string. Use '' instead. This is because in IE, when JavaScript passes string to PHP, null would become 'null'.
1. If one want to include everything, null, empty string, number 0, and even string “0”, the best approach is to use if(empty($var)).
2. If one wants to include null and empty string and exclude number 0, if(0==strlen(trim($var)) might be best approach. However, this approach is unable to detect the string "null".
3. If one wants to include null and number 0 and exclude empty string, the best approach maybe if(is_null($var) || 0==$var).
4. If one wants to only include null and exclude empty string and number 0, the best approach is if(is_null($var)). However, since both JavaScript and PHP does not tell the data type when declare a variable, it somehow easily to be mixed up the undefined variable or null variable with empty string. It is therefore suggested extra caution shall be applied to exclude empty string.
5. In most case people dealing with null would include undefined variable, null variable, empty string in JavaScript and PHP. For special case mentioned above for IE, it would includes string "null" as well, which isn't covered by Conclustion 2. So, the possible most save approach is put two together:
if(0==strlen(trim($var)) || "null"==$var)
6. To deal with undefined array, please refer to http://koncordpartners.blogspot.com/2009/12/number-of-elements-of-array.html.
http://ca2.php.net/manual/en/function.empty.php
Subscribe to:
Posts (Atom)
Labels
- :: (1)
- ? (1)
- .bat (1)
- .css (1)
- .getElementById (1)
- .htaccess (2)
- .html (1)
- .iso (3)
- .js (2)
- .js.php (2)
- .length (1)
- .parent (1)
- .php (1)
- .replace() (3)
- .replace(RegExp) (2)
- .search() (2)
- .SendMail (1)
- .sql (1)
- .style.height (1)
- .write (1)
- 'N' (1)
- 'null' (1)
- 'title' (1)
- 'undefined' (2)
- "Canvas" (1)
- "top()" (1)
- ( (1)
- () (1)
- (a) (1)
- (a)count() (1)
- [ (1)
- [...] (1)
- [0] (1)
- [rsInvalidDataSetName] The table ‘table1’ refers to an invalid DataSetName (1)
- { (1)
- * (1)
- \ (1)
- \n (2)
- \t (1)
- % (2)
- %...% (1)
- ^ (1)
- + (1)
- | (1)
- $ (1)
- $end (1)
- $this- (1)
- 0 (1)
- 1 OR -1 (1)
- 1280x1024 (1)
- 1680x1050 (1)
- 1920x1200 (1)
- 1σ (1)
- 2560x1600 (1)
- 32-bit (2)
- 34.1% (1)
- 3rd Normal Form (1)
- 64-bit (2)
- 7680x4800 (1)
- a (2)
- Access (1)
- Across Different Rows (1)
- Across HTML Pages (1)
- Action Query (1)
- Active (1)
- ActiveWorkbook (1)
- ADD COLUMN (1)
- Address (1)
- ADDRESS() (1)
- AdSense (1)
- Advanced Editing Toolbar (1)
- Aggragate function (1)
- AJAX (2)
- Algorithm (1)
- ALTER TABLE (1)
- Analytic Functions (1)
- Anchor (1)
- Annualized Projection (1)
- Anonymous Function (1)
- Another Table (1)
- ANSI SQL (1)
- Append Array Into Another Array (1)
- ArcCatalog (1)
- ArcEditor (2)
- ArcGIS (1)
- ArcMap (1)
- Arithmetic Mean (1)
- Array (6)
- Array Data Type (1)
- Array Slice (1)
- Array Type (1)
- array_merge() (1)
- array_push() (1)
- Artificial Intelligence (1)
- ASCII (1)
- ASCII Key Code (1)
- ASPX (1)
- Assembly (1)
- Associative Array (3)
- Attribute (2)
- Atul Kumar (1)
- Auto-Number (1)
- AUTOINCREMENT (1)
- Automatic (1)
- Automatic Login (1)
- Automatically Added Element (1)
- Automation (3)
- availHeight (1)
- AVG() (1)
- Aviation (1)
- Background Image (1)
- Batch File (1)
- bcc (1)
- Best Length (1)
- BI (2)
- Big5 (1)
- Bind Variable (5)
- blog.dwnews.com (1)
- Bookmarks (1)
- Boolean (1)
- Bracket (4)
- Bracket () (1)
- Browser (1)
- Bug (2)
- Bulk (1)
- Bulk Collect (1)
- Business Intelligence (2)
- Button (1)
- C# (1)
- c2coff (1)
- Calculation (1)
- Calendar Control (1)
- Caps Lock (1)
- CASE (5)
- CAST (1)
- cc (1)
- CD/DVD (1)
- CDO (1)
- CEIL (1)
- Cell (3)
- Charset (1)
- Checkbox (1)
- Chinese Characters (2)
- Chute Time (1)
- Circle (1)
- Class (2)
- Class Selector (1)
- Clean Code (1)
- Clean Computer (1)
- clientHeight (1)
- Clipboard (1)
- Closing Identifier (1)
- Closures (1)
- Code Editor (1)
- Code Cleaning (3)
- Code Cleanser (1)
- Code Compress (1)
- Code Compression (1)
- Code Compressor (1)
- Code Conventions (4)
- Code Optimization (1)
- Code Optimizer (1)
- Collection (1)
- Color Code in HTML (1)
- Column Alias (1)
- Column Name (3)
- Comma (1)
- Comments (2)
- Compact and Repair (1)
- Comparison (1)
- Comparison of IF Statement (1)
- Computer Science (1)
- Concatenation (1)
- Condition Set (1)
- Conditions (1)
- contentWindow (1)
- Convert (1)
- Convert String To Reference (1)
- CONVERT() (4)
- Coordinates Parse (1)
- Copy (3)
- count() (1)
- Create (1)
- Create Table (1)
- CREATE VIEW (1)
- Crimson Editor (1)
- Cross Join (1)
- Cross Windows (1)
- Crystal Reports (2)
- Crystal X (1)
- Crystal XI (1)
- CSS (4)
- Ctri+Shit+Enter (1)
- cx (1)
- Data Connection Wizard (1)
- Data Layout (1)
- Data Layout in Report (1)
- Data Type (2)
- Data Warehouse (1)
- Database (3)
- Dataset (2)
- DataSetName (1)
- Datatype (1)
- Date Format (2)
- DATEADD() (1)
- DATEDIFF() (1)
- DATEPART() (1)
- Dates Inclusive (1)
- Days in Month (1)
- DBA (1)
- Debug (1)
- Decimal Place (2)
- Decimal Point (2)
- DECIMAL() (1)
- DECODE (1)
- Default Database (1)
- Delegate (1)
- DELETE (3)
- Deleted Records (1)
- Delimited By Comma (1)
- Denormalized Data Structure (1)
- Deprecation (1)
- Description (1)
- DHTML (8)
- Dialogue Window (1)
- Different Servers (1)
- DISABLE CONSTRAINT (1)
- Disk Image (1)
- Disk Space (1)
- Disorderly Sorting Criterion (1)
- DISTINCT (1)
- Distributed Computing (1)
- DIV (2)
- DO (1)
- document.body.appendChild() (1)
- document.body.clientHeight Does Not Work (1)
- document.body.clientWidth/Height (1)
- document.body.offsetWidth/Height (1)
- document.createElement() (1)
- document.documentElement.clientWidth/Height (1)
- document.getElementById().innerHTML (2)
- document.getElementById().value (1)
- document.write() (3)
- Does Not Calculate (1)
- DOM (1)
- domain (1)
- Don Burleson (1)
- Double Quote (1)
- Drag and Drop (1)
- Draw Circle (1)
- DROP (1)
- Drop Down List (1)
- DSN (1)
- Dump Tests (1)
- Dynamic (2)
- Dynamic Codes (2)
- Dynamic Column Name (1)
- Dynamic Column Numbers (2)
- Dynamic Columns (1)
- Dynamic Dimension (1)
- Dynamic HTML (7)
- Dynamic Query (3)
- Dynamic SQL (2)
- Dynamic Table Name (1)
- Element (1)
- Embed (2)
- Empty String (1)
- empty() (1)
- ENABLE CONSTRAINT (1)
- Enable PHP (3)
- Encapsulation (2)
- End Bracket (2)
- End Tag (2)
- Enforce Width (1)
- Equivalent of window.innerWidth/Height (1)
- Error (2)
- Error Console (1)
- Error Massage (1)
- Error Message (10)
- Error message: Operation must use an updateable query (1)
- Error Number 2950 (1)
- Error: Function expected (1)
- Error: Invalid argument (1)
- Error: is not a function (1)
- Escape (1)
- Escape Sequence (2)
- eval() (1)
- Event (2)
- Examination (1)
- Exams (1)
- Excel (6)
- Excel 2003 (1)
- Excel 2007 (1)
- Excel Functions (1)
- EXEC (3)
- EXEC sp_executesql (1)
- EXEC() (1)
- EXECUTE (2)
- EXECUTE() (1)
- Existing (1)
- Existing Table (1)
- Explain Plan (1)
- explode() (1)
- External Data (1)
- FALSE (1)
- Fast (1)
- Fatal error: Call to undefined function... (1)
- Favorites (1)
- FileFormat (1)
- Firefox (3)
- First Day in Week (1)
- First Element (1)
- First Week in Month (1)
- First Week in Year (1)
- Fiscal Year (1)
- Flag (1)
- Float (1)
- FLOOR (1)
- for...in (1)
- Force Download (1)
- Force Update (1)
- Forecast (1)
- Form (6)
- Format (2)
- Format Cells (1)
- Formula (2)
- Formula Shown Up (1)
- Friday (1)
- Function (2)
- Function Declaration (2)
- Function Literal (4)
- Function Object (1)
- Function Passing (2)
- Function Pointer (3)
- Function Reference (3)
- GB (1)
- GB18030 (2)
- GB2312 (1)
- GB2312-80 (1)
- General (1)
- Geodata (2)
- getElementId() (1)
- GIS (3)
- Global Temprary Table (1)
- Google (4)
- Google Maps (1)
- GROUP BY (3)
- GTT (1)
- Handwriting (1)
- Hardware Engineering (1)
- header() (1)
- Heredoc (1)
- Hexadecimal (1)
- Hierarchy (1)
- Historic Data (1)
- hl (1)
- Homepage (2)
- Horizontal (1)
- Hour (1)
- Hover (1)
- Howard Stone (1)
- href= (1)
- HTML (20)
- HTML Color Code (1)
- HTML Loading Sequence (1)
- HTML Shows Nothing (1)
- HTML Table (1)
- http (1)
- HVM (1)
- IA64 (1)
- IDE (1)
- Identifier (1)
- Identifier URL (1)
- Identify (1)
- ie (6)
- IE 8 (1)
- IE Bug (2)
- IF (1)
- IF ELSE (1)
- IF ELSE Statement (2)
- IF Statement (1)
- if() (1)
- iFrame (3)
- iFrame Height (1)
- IIF (1)
- IIF() (1)
- Image (1)
- Import and Export Data (32-bit) (1)
- Importing Identifier (1)
- IN (1)
- Include (1)
- Indent (1)
- Indentation (3)
- Index (2)
- Indexed Array (2)
- INDIRECT() (1)
- Information Management (1)
- Information Science (1)
- Information Technology (1)
- Inheritance (1)
- INNER JOIN (2)
- Inner Query (2)
- innerHeight (1)
- Input (1)
- Input Item (1)
- Insert (2)
- Installer Structure (1)
- Instantiation (1)
- INT (1)
- Integer (1)
- Interface (2)
- Internet Explorer (4)
- Internet Explorer 8 (1)
- Interquartile Mean (2)
- Intersection (1)
- Invalid Argument (1)
- IQM (3)
- is not a function (1)
- IS NULL (1)
- Is Number (1)
- Is Numeric (1)
- is_float() (1)
- is_int() (2)
- is_null() (1)
- is_numeric() (3)
- Is_numeric() 0 (1)
- is_string() (1)
- isNumber (1)
- ISNUMBER() (1)
- ISO 8601 (1)
- iso Date Format (1)
- iso Format (3)
- ISO Image (3)
- isset() (1)
- IT (1)
- IT Certification (1)
- IT Exames (1)
- Itzik Ben-Gan (1)
- Japanese (1)
- Japanese Characters (1)
- Java (3)
- JavaScript (35)
- JavaScript Array (3)
- JavaScript Block (1)
- JavaScript Debug (1)
- JavaScript Download (1)
- JavaScript Event (1)
- JavaScript File (1)
- JavaScript File Download (1)
- Javascript File Generated by PHP (1)
- JavaScript Key Code (1)
- JavaScript Keycode (1)
- Javascript to PHP (1)
- JeSO (1)
- Job (2)
- Join (1)
- JS (1)
- JSON (3)
- JSON Format (1)
- Ken Stevens (2)
- Key (4)
- Key Word (1)
- Key-only Array (1)
- Keyword (2)
- Koncord (3)
- Koncord Applied Excel Functions (2)
- Koncord Cleanser (1)
- Koncord Homepage (2)
- Korean (1)
- Korean Characters (1)
- Lambda Expression (1)
- Landscape (1)
- lang_zh_Hans (1)
- lang_zh_Hant (1)
- Language (3)
- Languages (1)
- Large Array (1)
- Last Weekday (1)
- last_day (2)
- Latitude (2)
- Leap Year (1)
- Length (3)
- Line Break (1)
- Linear String (1)
- Link (2)
- Linked Server (1)
- Linux (1)
- ListBox (1)
- Literal (3)
- Loading (1)
- Local Address (1)
- Logic (1)
- Logic Bug (2)
- Logic Error (2)
- Long URL (1)
- Longitude (2)
- Loop Statement (1)
- LPAD (1)
- lr (1)
- Machine read (1)
- Macro (1)
- Macros (1)
- Marker (1)
- Match (2)
- Mathematics (1)
- Max (1)
- Max Length (3)
- Max Size (1)
- MAX() (1)
- Mean (1)
- Median (1)
- Megapixels (1)
- Memory (1)
- meta (1)
- Method (1)
- Micro (1)
- Microsoft Access (2)
- Microsoft Bug (1)
- Microsoft Excel (1)
- Microsoft Office Access (1)
- Microsoft Visual Studio 2005 (1)
- Microsoft Visual Studio 2008 (1)
- Military Time (1)
- Minute (1)
- Missing Hard Disk Space (1)
- mod_rewrite (2)
- Modular Programming (1)
- Modules (2)
- Monday (1)
- Monitor (1)
- Move (2)
- MS Access (13)
- MS Access 2000 (1)
- MS Access 2007 (1)
- Ms Excel (1)
- Multi-statement Table-Valued Function (1)
- Multidimensional Array (5)
- Multiple Email Recipients (1)
- Multiple Parameters (1)
- Multiple Recipients (1)
- Multiple-Value Parameter (1)
- multiple-value parameters (1)
- MySQL (5)
- MySQL 5.1 (1)
- MySQL Query (1)
- Name (1)
- Namespace (1)
- NaN (1)
- NCHAR (1)
- Nested Array (1)
- Nested Functions (1)
- Nested Object Namespacing (1)
- New (1)
- Newline (2)
- No Selection (1)
- non-fatal error (1)
- Normal Form (1)
- Normally Distributed Data (1)
- not a function (1)
- NOT IN (1)
- Notepad (2)
- Nothing (1)
- Nowdoc (1)
- NTEXT (1)
- Null (5)
- Number (1)
- Number 0 (1)
- Number of Elements (1)
- Numeric (2)
- Numerical Data Type (2)
- NVARCHAR (2)
- Object (3)
- Object Oriented (1)
- Object-Oriented (1)
- ODBC (2)
- OLAP (1)
- OLAP Database (1)
- OLTP (1)
- onChange (1)
- One-stroke Handwriting (1)
- onkeydown (1)
- onkeypress (1)
- Online (1)
- onload event (2)
- OO (1)
- OpenID (1)
- OpenID 1.1 (1)
- Operation must use an updateable query (1)
- Option (1)
- Option List (2)
- Optional Parameters (1)
- optionSelected (1)
- Oracle (7)
- Oracle Application Patch (1)
- Oracle Enterprise Linux (4)
- Oracle Procedure (1)
- Oracle VM (1)
- Oracle VM Template (1)
- Oracle XML Function (1)
- ORDER BY (3)
- Outer Join (1)
- Outer Query (1)
- OUTPUT (2)
- OVER PARTITION BY (1)
- Override Order (2)
- Parameter (7)
- Parameter Management (2)
- Parameter Sequence (1)
- Parameters (2)
- Parentheses () (1)
- Parse Error (1)
- Parsing Inside (1)
- PARTITION (1)
- Passing Array (1)
- Passing Function (2)
- Passing Name (1)
- Passing Reference (1)
- Passing Value (1)
- Passing Value iFrame (1)
- Paste (2)
- Paste Values (1)
- Patch (1)
- Percent (2)
- Percentage (1)
- Percentage Format (1)
- Performance (1)
- Performane Tuning (2)
- Permission (1)
- Peter Michaux (1)
- PHP (19)
- PHP Array (2)
- PHP Tag (1)
- PHP Wrapping JavaScript Debugging Method (2)
- phpinfo() (1)
- PIVOT (4)
- Pixel (1)
- PL/SQL (8)
- Portrait (1)
- Precise Radius (1)
- Prefix 'N' (1)
- Preselected (1)
- Privacy (1)
- Private (3)
- Private Search Engine (2)
- Probability Distribution (1)
- Procedure (1)
- Progress Bar (1)
- Project (1)
- Projection (1)
- Protected (1)
- Prototype (1)
- Public (3)
- public_html (1)
- Publisher ID (1)
- Pure Code Editor (1)
- push() (1)
- PV (1)
- q (1)
- Q and A (5)
- qmchenry (1)
- Radius (1)
- Random Access (1)
- Reconstruct Function (1)
- Recover (1)
- Recovery (1)
- Redirect (2)
- ref cursor (1)
- Reference (2)
- Reference Instantiate (1)
- RegExp (4)
- Regular (1)
- Regular Expression (1)
- Remote Server (1)
- Removal (1)
- Remove (1)
- Report (6)
- Reporting (1)
- Reporting Services (2)
- Reporting Services Database (1)
- ReportingServices.js (1)
- Require (1)
- Resolution (1)
- RewriteEngine (1)
- RewriteOptions (1)
- RewriteRule (1)
- Rizal Almashoor (1)
- Robotics (1)
- Ron de Bruin (1)
- ROUND() (2)
- ROUNDDOWN() (1)
- Rounding (1)
- Row (1)
- Row to Column (1)
- ROWNUM (1)
- sa (1)
- Saturday (1)
- Save As (1)
- SaveAs (1)
- Schedule (2)
- Screen Size (1)
- Script (1)
- Script File (2)
- scrollHeight (1)
- Search (2)
- Search Engine (4)
- Seasonal Adjustment (1)
- Secret Process (1)
- SELECT (4)
- Select List (1)
- SELECT PIVOT (2)
- SELECT TOP (1)
- Selected Item (1)
- selectedIndex (1)
- Selector (1)
- Self JOIN (1)
- Self-ting Temporary Function (1)
- self:: (1)
- SEO (2)
- Sequence (3)
- Sequence of Parameters (1)
- Sequence to Execute Modules (2)
- Sequential Number (1)
- Sequential Programming (1)
- Series Number (1)
- Server Virtualization (1)
- set (4)
- SET NAMES (1)
- SETI(a)home (1)
- setInterval (2)
- setTimeout (1)
- SetWarnings (1)
- Shared Server (1)
- Show/Hide (1)
- SHP (1)
- sign() (1)
- Simplified Chinese (2)
- SIZE (1)
- sizeof() (1)
- Slow Computer (1)
- Smifis (1)
- Software Engineering (1)
- Solution (1)
- Sort (1)
- Sorting (2)
- Sorting Order (1)
- SP (1)
- sp_executesql (2)
- Space (1)
- SPAN (1)
- Specific Radius (1)
- Speed (1)
- sq_addlinkedserver (1)
- sq_addlinkedsrvlogin (1)
- SQL (5)
- SQL Editor (1)
- SQL Query (1)
- SQL Server (12)
- SQL Server Agent (1)
- SQL Server Analysis Services (1)
- SQL Server Business Intelligence Development Studio (1)
- SQL Server Integration Services (1)
- SQL Server Management Studio (2)
- SQL Server Native Client 10.0 (2)
- SQL Server Reporting Services (6)
- SQL Server Reporting Services 2005 (2)
- SSAS (1)
- SSIS (1)
- SSRS (7)
- SSRS 2005 (3)
- SSRS 2008 (2)
- SSRS Parameter (1)
- Standard Deviation (2)
- Startup (1)
- Stateless (1)
- Static (2)
- Status Bar (1)
- STD() (1)
- STDDEV() (1)
- STDEVP() (1)
- Stored Procedure (7)
- String (6)
- String 'null' (1)
- String 0 (1)
- String Parse (1)
- String Reference (2)
- Stringify (1)
- stringify() (1)
- strlen() (1)
- Style Properties (1)
- subdomain (1)
- SUBSTRING (1)
- SUM() (2)
- SUM(CASE) GROUP BY Method (3)
- Summation (1)
- Summation of Hours (1)
- Sunday (1)
- Suppress (1)
- T-SQL (26)
- Tab (2)
- Table (3)
- Table Name (2)
- Table of Contents (1)
- Table Structure (1)
- Table Type (1)
- Table() (1)
- Task Manager (1)
- td (2)
- Telephone Number Parse (1)
- Temp Table (2)
- Temporary Table (2)
- Terms (1)
- Terms Of Services (1)
- Test Books (1)
- Text (1)
- The report definition is not valid (1)
- The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a (1)
- this (2)
- Thursday (1)
- Tin() (1)
- TINYINT (1)
- Tinyint() (1)
- Title (1)
- To_number() (1)
- Today() (1)
- Tool (1)
- Toolbar (1)
- TOP (1)
- TOP (n) PERCENT (1)
- Total (1)
- tr (1)
- Traditional Chinese (2)
- Transact-SQL (2)
- TRANSFORM (4)
- Transpose (4)
- trim() (1)
- TRUE (1)
- Truncate (2)
- Tuesday (1)
- Tutorial (7)
- typeof() (1)
- undefined() (1)
- UNDELETE (1)
- UNDO (1)
- Uneven Array (1)
- Unexpected $end (1)
- Unicode (2)
- Unicode 3.0 (1)
- UNION (5)
- UNION ALL (1)
- Unknown Dimentions (1)
- Unneeded Parameters (1)
- unset() (2)
- Unwanted Parameters (1)
- Update (2)
- Upload (1)
- Upload Data (1)
- Upper letters (1)
- Urban Legend (1)
- URL (1)
- URL Redirect (2)
- Usability (1)
- use Varibalized Function (1)
- UTF-16 (1)
- UTF-8 (1)
- UTF8 (1)
- Value (2)
- Value Passing (1)
- var (1)
- VARCHAR (1)
- Varchar To Integer (1)
- VARCHAR(MAX) (2)
- Variable Assignment (1)
- Variable Declaration (1)
- Variable Passing (2)
- Variablized Function (4)
- VB6 (2)
- VBA (3)
- VDS (1)
- Vertical (1)
- Virtual Dedicated Server (1)
- Virtual Private Server (1)
- Virtual URL (1)
- Visited (1)
- Visual Basic 6.0 (2)
- Visual Studio (1)
- VMware (1)
- VMware Server (2)
- VPS (1)
- WebSearch (1)
- Wednesday (1)
- Week Start Day (1)
- WEEKDAY (1)
- WEEKDAY() (2)
- WHERE (2)
- WHERE Condition (3)
- WHERE IN (1)
- WHERE NOT IN (1)
- Whitespace (2)
- WHUXGA (1)
- Width (1)
- window.innerWidth (1)
- window.onload Event (1)
- Windows Authentication (1)
- windows.event (1)
- WIP (1)
- WITH (2)
- With Parameter (1)
- Without Data (1)
- word-wrap: break-word; (1)
- www. (1)
- www2 (1)
- XML (1)
- XML cannot be the whole program (1)
- XML Tag (1)
- Year-To-Date (1)
- ZEROFILL (1)
- zh-Hans (1)
- zh-Hant (1)
- σ (1)