informatique:php:tips
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| informatique:php:tips [09/11/2010 09:49] – cyrille | informatique:php:tips [02/10/2025 18:02] (Version actuelle) – [Pointeur de fonction] cyrille | ||
|---|---|---|---|
| Ligne 26: | Ligne 26: | ||
| http:// | http:// | ||
| + | |||
| + | =====Sécurité===== | ||
| + | |||
| + | [[http:// | ||
| + | |||
| ===== Divers ===== | ===== Divers ===== | ||
| Ligne 39: | Ligne 44: | ||
| ==== RegEx ==== | ==== RegEx ==== | ||
| - | Validation | + | === syntaxe adresse email === |
| <code php> | <code php> | ||
| Ligne 53: | Ligne 58: | ||
| </ | </ | ||
| + | Voir aussi [[http:// | ||
| + | |||
| + | === Collation caractères unicode === | ||
| + | |||
| + | Pour prendre les caractères accentués ou autres de la langue française: é, è, ê, ù, ç, É, À, ... Utiliser la classe de caractères '' | ||
| + | |||
| + | < | ||
| + | // match les caractères français et espace et tiret: | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Pour comparer des mots avec caractères accentués (diacritics) sans tenir compte des accents: | ||
| + | <code php>$s1 = 'en été ça va là' ; | ||
| + | $s2 = 'en ÉTE Ça va Là' ; | ||
| + | $s1 = strtolower( iconv( ' | ||
| + | $s2 = strtolower( iconv( ' | ||
| + | echo ' | ||
| ====Cross Platform ==== | ====Cross Platform ==== | ||
| Ligne 80: | Ligne 102: | ||
| http:// | http:// | ||
| + | |||
| + | ==== Merge object inheritance property ==== | ||
| + | |||
| + | Chaque classe d'une chaîne d' | ||
| + | Pour fusionner les valeurs de cette propriété : | ||
| + | |||
| + | <code php> | ||
| + | $class = get_called_class(); | ||
| + | while ($class = get_parent_class($class)) { | ||
| + | $data = get_class_vars($class)[' | ||
| + | if( is_array($data)) | ||
| + | // aka " | ||
| + | $this-> | ||
| + | } | ||
| + | </ | ||
| ==== Singleton ==== | ==== Singleton ==== | ||
| Ligne 87: | Ligne 124: | ||
| ==== Manipulation fichier Excel ==== | ==== Manipulation fichier Excel ==== | ||
| - | [[http:// | + | * [[https:// |
| + | * [[http:// | ||
| Le package Spreadsheet_Excel_Writer | Le package Spreadsheet_Excel_Writer | ||
| Ligne 94: | Ligne 132: | ||
| / | / | ||
| </ | </ | ||
| + | |||
| + | ==== Mysqlnd ==== | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | ==== Network ==== | ||
| + | |||
| + | === Wake On Lan (WOL) === | ||
| + | |||
| + | <code php> | ||
| + | # Wake on LAN - (c) HotKey@spr.at, | ||
| + | # Modified by Allan Barizo http:// | ||
| + | flush(); | ||
| + | function WakeOnLan($addr, | ||
| + | $addr_byte = explode(':', | ||
| + | $hw_addr = ''; | ||
| + | for ($a=0; $a <6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a])); | ||
| + | $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255); | ||
| + | for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr; | ||
| + | // send it to the broadcast address using UDP | ||
| + | // SQL_BROADCAST option isn't help!! | ||
| + | $s = socket_create(AF_INET, | ||
| + | if ($s == false) { | ||
| + | echo "Error creating socket!\n"; | ||
| + | echo "Error code is '" | ||
| + | return FALSE; | ||
| + | } | ||
| + | else { | ||
| + | // setting a broadcast option to socket: | ||
| + | $opt_ret = socket_set_option($s, | ||
| + | if($opt_ret <0) { | ||
| + | echo " | ||
| + | return FALSE; | ||
| + | } | ||
| + | if(socket_sendto($s, | ||
| + | echo "Magic Packet sent successfully!"; | ||
| + | socket_close($s); | ||
| + | return TRUE; | ||
| + | } | ||
| + | else { | ||
| + | echo "Magic packet failed!"; | ||
| + | return FALSE; | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9. | ||
| + | $socket_number = " | ||
| + | // MAC Address of the listening computer' | ||
| + | $mac_addy = " | ||
| + | // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP) | ||
| + | $ip_addy = gethostbyname(" | ||
| + | | ||
| + | WakeOnLan($ip_addy, | ||
| + | |||
| + | </ | ||
| + | |||
| + | === Import gros fichier === | ||
| + | |||
| + | Upload large file. | ||
| + | |||
| + | == Php side == | ||
| + | |||
| + | * memory_limit | ||
| + | * upload_max_filesize | ||
| + | * post_max_size | ||
| + | |||
| + | To use with Laravel and JS libraries look at [[https:// | ||
| + | == Nginx side == | ||
| + | |||
| + | |||
| + | == Client side (chunking) == | ||
| + | |||
| + | * javascript | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Cross-site chunked uploads: by default, browsers don't allow all headers used for cross-site file uploads, if they are not explicitly defined as allowed with the following server-side headers: | ||
| + | < | ||
| + | Access-Control-Allow-Headers Content-Type, | ||
| + | </ | ||
| + | |||
informatique/php/tips.1289292569.txt.gz · Dernière modification : (modification externe)
