PHP: Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== References == |
== References == |
||
* [http://php.net/manual/en/langref.php Language reference on php.net] |
|||
TBC |
|||
* [http://www.w3schools.com/php/default.asp php tutorial on w3schools.com] (check the menu on the left) |
|||
:* [http://www.w3schools.com/php/php_ref_string.asp string functions] |
|||
Cheat sheets: |
|||
* [https://dzone.com/refcardz/php-54-scalable php DZone cheat sheet] |
|||
== Syntax == |
== Syntax == |
Revision as of 23:45, 2 January 2016
References
- Language reference on php.net
- php tutorial on w3schools.com (check the menu on the left)
Cheat sheets:
Syntax
/* arrays */
$attr = array(); // an empty array
$attr = array("border"=>"myborder", "mode"=>"mymode"); // associative array
/* strings */
'abc' . 'def' // concatenation
"abc $var def" // variable reference in strings
$s=str_replace("\n","",$s); // Replace a substring in a string
$s=str_replace(array("\r","\n","\t"," "),"",$s; // ... idem, with several substrings (also support several "replace" strings)
/* constant */
NULL; // The null reference
Unicode support
- First, if PHP file contains special character, make sure the PHP file is encoded in UTF-8:
file -bi FenTT.php # To get current encoding
iconv -f $encoding -t UTF-8 -o FenTT.out.php FenTT.php # Specify correct source $encoding as given above (note that converting us-ascii is useless)
- Specify the default multi-byte encoding:
mb_internal_encoding("UTF-8");
- Next store unicode char as follows [1]:
$S = '\u2654\u2655\u2656\u2657';
$S = json_decode('"'.$S.'"');
$D = mb_substr($S,2,1); // instead of $D=$S[2]