Quelques fonctions utiles en PHP. Chaînes de caractères int eregi ( string pattern, string string [, array &regs] ) <?php $string = ‘drosophila melanogaster';

Présentations similaires


Présentation au sujet: "Quelques fonctions utiles en PHP. Chaînes de caractères int eregi ( string pattern, string string [, array &regs] ) <?php $string = ‘drosophila melanogaster';"— Transcription de la présentation:

1 Quelques fonctions utiles en PHP

2 Chaînes de caractères int eregi ( string pattern, string string [, array &regs] ) <?php $string = ‘drosophila melanogaster'; if (eregi(‘droso', $string)) {echo "'$string' fait partie de la famille des mouches";} ?> string eregi_replace ( string pattern, string replacement, string string )

3 Chaînes de caractères string substr ( string string, int start [, int length] ) echo substr('abcdef', 1); // bcdef echo substr('abcdef', 1, 3); // bcd int strlen ( string string ) $str = 'abcdef'; echo strlen($str); // 6 string ucfirst ( string str ) $str = 'bonjour tout le monde!'; $str = ucfirst($str); // Bonjour tout le monde! ucwords  masjucule 1 ère lettre tous les mots (différent de lcfirst) strtolower  minuscule partout (différent de strtoupper)

4 Chaînes de caractères array split ( string pattern, string string [, int limit] ) "; ?>

5 Chaînes de caractères array explode ( string delimiter, string string [, int limit] ) <?php // Exemple de la bonne pizza!!! $pizza = "fromage champignons jambon oeuf"; $pieces = explode(" ", $pizza); echo $pieces[0]; // fromage echo $pieces[1]; // champignons ?>

6 Mails bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )  to : destinataires  subject:sujet du mail  message: message du mail (lignes séparées par des \n  headers: en-tête ajouté mail(‘reichma@clermont.in2p3.fr’, 'Mon Sujet', $message);

7 Dossiers void closedir ( resource dir_handle ) resource opendir ( string path ) string readdir ( resource dir_handle ) if (is_dir($dir)) { if ($dh = opendir($dir)) { $directory = readdir($dh); closedir($dh); } }

8 Références http://www.info-3000.com/phpmysql/listecompletefonction.php


Télécharger ppt "Quelques fonctions utiles en PHP. Chaînes de caractères int eregi ( string pattern, string string [, array &regs] ) <?php $string = ‘drosophila melanogaster';"
Annonces Google