\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Zetura (Zetura)} \pdfinfo{ /Title (php-syntaxe-and-fondamentaux-fr.pdf) /Creator (Cheatography) /Author (Zetura (Zetura)) /Subject (PHP Syntaxe \& Fondamentaux - FR Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{00B3FF} \definecolor{LightBackground}{HTML}{EFFAFF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{PHP Syntaxe \& Fondamentaux - FR Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Zetura (Zetura)} via \textcolor{DarkBackground}{\uline{cheatography.com/18426/cs/1752/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Zetura (Zetura) \\ \uline{cheatography.com/zetura} \\ \uline{\seqsplit{atago}.fr} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th February, 2014.\\ Updated 12th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.23965 cm} x{2.73735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Syntaxe de base}} \tn % Row 0 \SetRowColor{LightBackground} Code PHP & \textless{}?php //Contenu ?\textgreater{} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Commentaire sur une ligne & // Commentaire \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} Commentaires sur plusieurs lignes & /* Commentaire */ \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Fin d'instruction & ; \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} Inclusion de fichier & \seqsplit{require\_once('nom\_fichier}.php'); \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variables et Constantes}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\$nomVariable = "Chaine de caractere";} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\$nomVariable = 'Chaine de caractere';} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\$nomVariable = 5;} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\$nomVariable = "Une \{\$autreVariable\} info";} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{echo \$nomVariable;} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{global \$varGlobale;} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{echo \$GLOBALS{[}'varGlobale'{]}} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{define('NOMCONSTANTE', 'valeur');} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{echo NOMCONSTANTE;} \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Fonctions sur les variables}} \tn % Row 0 \SetRowColor{LightBackground} Vérifier l'existence de la variable & isset(\$var); \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Détruire une variable & unset(\$var); \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Connaître le type & gettype(\$var); \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} Vérifier un type & is\_{[}type{]}(\$var); Ex : is\_string(\$var); \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Cast (changement de type) & \$var = (string) \$var; \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Conversion de valeur & {[}type{]}val(\$var); Ex : intval(\$var); \$floatval(\$var); \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} Test si la variable est vide & empty(\$var); \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Tableaux}} \tn % Row 0 \SetRowColor{LightBackground} Création & \$tableau = array(); \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Ajout & \$tableau{[}{]} = "valeur"; \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} Ajout sur un index & \$tableau{[}4{]} = "valeur"; \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Ajout sur une clé & \$tableau{[}"cle"{]} = "valeur"; \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Création numérique & \$tableau = array('valeur1', 'valeur2'); \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} Création associative & \$tableau = array('cle1' =\textgreater{} 'valeur1', 'cle2' =\textgreater{} 'valeur2'); \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} Ecriture depuis numérique & echo \$tableau{[}4{]}; \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} Ecriture depuis association & echo \$tableau{[}'cle1'{]}; \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} Tableaux numériques & Les clés sont des chiffres \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} Tableaux associatifs & Les clés sont des chaînes de caractères \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} Matrice (tableau multi-dimensions) & \$matrice{[}2{]}{[}3{]} = "valeur"; \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.46464 cm} p{0.50347 cm} x{2.60889 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Types}} \tn % Row 0 \SetRowColor{LightBackground} Booléen & \seqsplit{boolean} & true OU false \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Entier & \seqsplit{integer} & nombre positif ou négatif \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Nombre flottant & float & nombre à virgule positif ou négatif \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Nombre flottant & \seqsplit{double} & nombre à virgule positif uniquement \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Chaîne de caractère & \seqsplit{string} & chaîne de caractères \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Chaines de caracteres (string)}} \tn % Row 0 \SetRowColor{LightBackground} Délimités entre guillement ou apostrophe & "chaine de caractères" ou 'chaine de caractères' \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Entre guillement, les variables sont interprétés & \$var = caractères; echo "chaine de \$var"; \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} Caractère d'échappement & \textbackslash{} \tn % Row Count 8 (+ 2) % Row 3 \SetRowColor{white} Retour à la ligne & \textbackslash{}n \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} Retour chariot & \textbackslash{}r \tn % Row Count 10 (+ 1) % Row 5 \SetRowColor{white} Tabulation & \textbackslash{}t \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Fonction utilisateur}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{function multiplier(\$arg1, \$arg2) \newline % Row Count 1 (+ 1) \{ \newline % Row Count 2 (+ 1) return \$arg1 * \$arg2; \newline % Row Count 3 (+ 1) \} \newline % Row Count 4 (+ 1) \$param1 = 4; \newline % Row Count 5 (+ 1) \$param2 = 8; \newline % Row Count 6 (+ 1) \$resultat = multiplier(\$param1, \$param2);% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Classes and Objects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{class SomeClass \{ \newline % Row Count 1 (+ 1) ~~~~private \$property; \newline % Row Count 2 (+ 1) ~~~~public \$anotherProperty; \newline % Row Count 3 (+ 1) ~~~~protected \$yetAnotherProperty = null; \newline % Row Count 5 (+ 2) ~~~~public function \seqsplit{\_\_construct(\$arg=null)} \newline % Row Count 7 (+ 2) \{ \newline % Row Count 8 (+ 1) ~~~~\$this-\textgreater{}property = \$arg; \newline % Row Count 9 (+ 1) \} \newline % Row Count 10 (+ 1) public function someMethod() \newline % Row Count 11 (+ 1) \{ \newline % Row Count 12 (+ 1) ~~~~echo "Hi"; \newline % Row Count 13 (+ 1) \} \newline % Row Count 14 (+ 1) public function getProperty() \newline % Row Count 15 (+ 1) \{ \newline % Row Count 16 (+ 1) ~~~~return \$this-\textgreater{}property; \newline % Row Count 17 (+ 1) \} \newline % Row Count 18 (+ 1) public function setProperty( \$p ) \newline % Row Count 19 (+ 1) \{ \newline % Row Count 20 (+ 1) ~~~~\$this-\textgreater{}property = \$p; \newline % Row Count 21 (+ 1) \} \newline % Row Count 22 (+ 1) \} \newline % Row Count 23 (+ 1) \$myObject = new SomeClass( "123" ); \newline % Row Count 24 (+ 1) echo \$myObject-\textgreater{}getProperty(); // 123 \newline % Row Count 25 (+ 1) \$myObject-\textgreater{}property; // ERROR:private% Row Count 26 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.10542 cm} x{0.96117 cm} x{1.51041 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operateurs}} \tn % Row 0 \SetRowColor{LightBackground} Affectation & = & \$var = 5; \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Affectation par référence & \&= & \$nouvelVar \&= \$var; \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} Addition & + & \$var = \$var + 5; \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} Soustraction & - & \$var = \$var - 5; \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} Multiplication & * & \$var = \$var * 5; \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} DIvision & / & \$var = \$var / 5; \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} Modulo & \% & \$var = \$var \% 5; \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} Incrémentation & ++ & \$var = \$var++; \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} Décrémentation & -{}- & \$var = \$var-{}-; \tn % Row Count 17 (+ 2) % Row 9 \SetRowColor{white} Opérateurs combinés & {[}opérateur{]}= & \$var += 5; \$var *= 5; \tn % Row Count 19 (+ 2) % Row 10 \SetRowColor{LightBackground} Concaténation & . & echo \$var." chaine"; \tn % Row Count 21 (+ 2) % Row 11 \SetRowColor{white} Concaténation et assignation & .= & \$var .= " chaine"; \tn % Row Count 23 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.88351 cm} p{0.4577 cm} x{1.23579 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operateurs de comparaison}} \tn % Row 0 \SetRowColor{LightBackground} Egalité & == & if(\$var == 5) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Inférieur à & \textless{} & if(\$var \textless{} 5) \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Inférieur ou égal à & \textless{}= & if(\$var \textless{}= 5) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Supérieur à & \textgreater{} & if(\$var \textgreater{} 5) \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Supérieur ou égal à & \textgreater{}= & if(\$var \textgreater{}= 5) \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} Différent de & != & if(\$var != 5) \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} Strictement égal (valeur et type) & === & if(\$var === 5) \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} Différent en valeur ou en type & !== & if(\$var !== 5) \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Utlisés pour les structures conditionnelles} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.60195 cm} p{0.4577 cm} x{2.51735 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Operateurs logiques}} \tn % Row 0 \SetRowColor{LightBackground} Inversion & ! & Retourne true si false, et inversement \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ET & \&\& & Retourne true si 2 conditions à true \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Un seul & \textasciicircum{} & Retourne true si une seule des conditions à true \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} OU & || & Retourne true si une condition à true \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} ET non prioritaire & AND & Similaire à \&\& mais moins prioritaire \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} Un seul non prioritaire & XOR & Similaire à \textasciicircum{} mais moins prioritaire \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} OU non prioritaire & OR & Similaire à || mais moins prioritaire \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Utilisés pour les structures conditionnelles} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Fonctions PHP utiles}} \tn % Row 0 \SetRowColor{LightBackground} Récupérer une partie d'une chaîne & substr(\$string, start, length); \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Transformer une chaine en tableau & explode(',', \$string); \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Concaténer un tableau en chaine & implode(',', \$tableau); \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Retirer les espaces au début et à la fin d'une chaîne & trim(\$string); \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} Remplacer à par b dans une chaine & str\_replace('a', 'b', \$string); \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} Vérifier une expression régulière & preg\_match('regex', \$string); \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} Remplacer une expression régulière par b & \seqsplit{preg\_replace('regex'}, 'b', \$string); \tn % Row Count 16 (+ 3) % Row 7 \SetRowColor{white} Arrêter le script PHP & exit(); \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} Envoyer un mail & mail(\$mailDest, \$sujet, \$message, 'From: '.\$mailEnvoi); \tn % Row Count 21 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Expression reguliere}} \tn % Row 0 \SetRowColor{LightBackground} \textasciicircum{} & Début de chaîne \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textbackslash{}d & Chiffre entre 0 et 9 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textbackslash{}w & Caractère alphanumérique {[}0-9A-Za-z{]} \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \textbackslash{}s & Espace \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} . & N'importe quelle lettre, chiffre ou espace \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} \$ & Fin de chaîne \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} () & Groupe \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} {[}{]} & Classe de caractères \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} \{x\} \{x,\} \{x,y\} & Quantité = x | Supérieur ou égal à x | Entre x et y \tn % Row Count 12 (+ 2) % Row 9 \SetRowColor{white} * & Quantité de 0 ou plus \tn % Row Count 13 (+ 1) % Row 10 \SetRowColor{LightBackground} ? & Quantité de 0 ou 1 \tn % Row Count 14 (+ 1) % Row 11 \SetRowColor{white} + & Quantité de 1 ou plus \tn % Row Count 15 (+ 1) % Row 12 \SetRowColor{LightBackground} | & OU \tn % Row Count 16 (+ 1) % Row 13 \SetRowColor{white} \textbackslash{} & Caractère d'échappement \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Exemple pour une syntaxe de mail : \newline \textasciicircum{}{[}\textbackslash{}w.-\textbackslash{}+{]}+@{[}\textbackslash{}w.-{]}+\textbackslash{}.{[}a-zA-Z{]}\{2,6\}\$} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Structure conditionnelle : IF}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{if (condition) \{ \newline % Row Count 1 (+ 1) // Instructions \newline % Row Count 2 (+ 1) \} \newline % Row Count 3 (+ 1) elseif (condition) \{ \newline % Row Count 4 (+ 1) // Instructions \newline % Row Count 5 (+ 1) \} \newline % Row Count 6 (+ 1) else \{ \newline % Row Count 7 (+ 1) // Instructions \newline % Row Count 8 (+ 1) \} \newline % Row Count 9 (+ 1) if( \$something == true ) \{ \newline % Row Count 10 (+ 1) // Si \$something vaut true \newline % Row Count 11 (+ 1) doSomething(); \newline % Row Count 12 (+ 1) \} elseif ( \$something == false ) \{ \newline % Row Count 13 (+ 1) // Si \$something vaut false \newline % Row Count 14 (+ 1) doSomethingElse(); \newline % Row Count 15 (+ 1) \} else \{ \newline % Row Count 16 (+ 1) // sinon, exécuter doNothing(); \newline % Row Count 17 (+ 1) doNothing(); \newline % Row Count 18 (+ 1) \} \newline % Row Count 19 (+ 1) if(condition): \newline % Row Count 20 (+ 1) // Instructions \newline % Row Count 21 (+ 1) endif; \newline % Row Count 22 (+ 1) (condition)? instructions si true : instructions si false;% Row Count 24 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Structure conditionnelle : SWITCH}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{switch (\$var) \{ \newline % Row Count 1 (+ 1) case 1: \newline % Row Count 2 (+ 1) // Instructions \newline % Row Count 3 (+ 1) break; \newline % Row Count 4 (+ 1) case "test": \newline % Row Count 5 (+ 1) // Instructions \newline % Row Count 6 (+ 1) break; \newline % Row Count 7 (+ 1) default: \newline % Row Count 8 (+ 1) // Instructions \newline % Row Count 9 (+ 1) break; \newline % Row Count 10 (+ 1) \}% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Peut être utilisé avec des chiffres ou chaînes de caractères} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Boucle WHILE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Tant que la condition est vrai, l'instruction est exécutée \newline % Row Count 2 (+ 2) while(condition)\{ \newline % Row Count 3 (+ 1) // Instructions \newline % Row Count 4 (+ 1) \} \newline % Row Count 5 (+ 1) \$i = 1; \newline % Row Count 6 (+ 1) while(\$i \textless{} 10)\{ \newline % Row Count 7 (+ 1) echo \$i; \newline % Row Count 8 (+ 1) \$i++; \newline % Row Count 9 (+ 1) \} \newline % Row Count 10 (+ 1) Exécution au moins une première fois \newline % Row Count 11 (+ 1) \$i = 1; \newline % Row Count 12 (+ 1) do\{ \newline % Row Count 13 (+ 1) echo \$i; \newline % Row Count 14 (+ 1) \$i++; \newline % Row Count 15 (+ 1) \} \newline % Row Count 16 (+ 1) while(\$i \textless{} 10);% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Attention aux boucles infinies} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Boucle FOR}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Exécute la première expression lors de l'initialisation, puis tant que la condition est valide, exécute le contenu de la boucle et fini en exécutant la dernière expression \newline % Row Count 4 (+ 4) for(expression1; condition; expression2)\{ \newline % Row Count 5 (+ 1) // Instructions \newline % Row Count 6 (+ 1) \} \newline % Row Count 7 (+ 1) for(\$i = 1; \$i \textless{} 10; \$i++)\{ \newline % Row Count 8 (+ 1) // Instructions \newline % Row Count 9 (+ 1) \}% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Boucle FOREACH}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{A chaque itération dans la boucle assigne la valeur de l'élément courant à la variable et le pointeur interne du tableau est avancé d'un élément. \newline % Row Count 4 (+ 4) foreach(\$tableau as \$element)\{ \newline % Row Count 5 (+ 1) // Instructions \newline % Row Count 6 (+ 1) \} \newline % Row Count 7 (+ 1) foreach(\$tableau as \$key =\textgreater{} \$value)\{ \newline % Row Count 8 (+ 1) // Instructions \newline % Row Count 9 (+ 1) \} \newline % Row Count 10 (+ 1) \$tableau = array( \newline % Row Count 11 (+ 1) 'prenom' =\textgreater{} 'Obi-wan', \newline % Row Count 12 (+ 1) 'nom' =\textgreater{} 'Kenobi', \newline % Row Count 13 (+ 1) 'metier' =\textgreater{} 'Jedi' \newline % Row Count 14 (+ 1) ); \newline % Row Count 15 (+ 1) foreach(\$tableau as \$contenu)\{ \newline % Row Count 16 (+ 1) echo "Valeur : \$contenu\textless{}br/\textgreater{}"; \newline % Row Count 17 (+ 1) \} \newline % Row Count 18 (+ 1) foreach(\$tableau as \$cle =\textgreater{} \$valeur)\{ \newline % Row Count 19 (+ 1) echo "Clé : \$cle -\textgreater{} Valeur : \$valeur\textless{}br/\textgreater{}"; \newline % Row Count 20 (+ 1) \}% Row Count 21 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Attention, la boucle fonctionne sur une copie du tableau spécifié, pas sur le tableau lui-même} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CONTINUE}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{for (\$i = 0; \$i \textless{} 5; ++\$i) \{ \newline % Row Count 1 (+ 1) if (\$i == 2) \newline % Row Count 2 (+ 1) continue; \newline % Row Count 3 (+ 1) print "\$i , "; \newline % Row Count 4 (+ 1) \}% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{produces the following output: \newline 0 , 1 , 3 , 4} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}