14,983
edits
m (→timer) |
No edit summary |
||
| Line 201: | Line 201: | ||
* a >0 OR b > 0 OR c > 0 | * a >0 OR b > 0 OR c > 0 | ||
* a+b+c > 0 | * a+b+c > 0 | ||
== text / string == | |||
=== length of characters === | |||
* PHP: [http://php.net/mb_strlen PHP mb_strlen function] | |||
<pre> | |||
echo strlen("《王大文 Dawen》"); // return 21 | |||
echo mb_strlen("《王大文 Dawen》", 'UTF-8'); // return 11 | |||
</pre> | |||
* MySQL: [http://www.w3resource.com/mysql/string-functions/mysql-char_length-function.php MySQL CHAR_LENGTH() function] | |||
* Excel: [https://support.office.com/zh-tw/article/LEN%E3%80%81LENB-%E5%87%BD%E6%95%B8-29236f94-cedc-429d-affd-b5e33d2c67cb LEN 函數] | |||
* [http://string-functions.com/length.aspx Calculate String Length Online] | |||
=== text match === | |||
* PHP [http://php.net/manual/en/function.in-array.php in_array]; [http://api.jquery.com/jQuery.inArray/ jQuery.inArray()] | |||
<pre> | |||
//PHP code snippet: | |||
$array = array("AAA", "BBB", "CCC"); | |||
if(in_array($var, $array){ | |||
//do something | |||
} | |||
</pre> | |||
* preg_match... | |||
* verbose approach: {{exclaim}} IF (0 == 'String') always be true?<ref>[http://stackoverflow.com/questions/6843030/why-does-php-consider-0-to-be-equal-to-a-string Why does PHP consider 0 to be equal to a string? - Stack Overflow]</ref> | |||
<pre> | |||
if($var =="AAA" OR $var =="BBB" OR $var =="CCC"){ | |||
//do something | |||
} | |||
</pre> | |||
=== text input filter === | |||
* {{Gd}} [http://php.net/manual/en/pdo.prepare.php PHP: PDO::prepare] + [http://php.net/manual/en/pdostatement.bindparam.php PDOStatement::bindParam] | |||
* [http://www.php.net/manual/en/mysqli.real-escape-string.php PHP: mysqli::real_escape_string] | |||
== trigger to make backup of deleted data before deleting them == | == trigger to make backup of deleted data before deleting them == | ||
| Line 236: | Line 274: | ||
* (1)SELECT * FROM table; (2)Using [http://php.net/manual/en/function.array-unique.php PHP: array_unique] for data handling two or more columns | * (1)SELECT * FROM table; (2)Using [http://php.net/manual/en/function.array-unique.php PHP: array_unique] for data handling two or more columns | ||
* SELECT column FROM table GROUP BY column | * SELECT column FROM table GROUP BY column | ||
== export/import sql file == | == export/import sql file == | ||