Skip to content

Instantly share code, notes, and snippets.

@ChocW
ChocW / BDD
Last active April 24, 2019 12:17
Comment récupérer des données avec SELECT
mysql> SELECT * FROM wizard WHERE birthday BETWEEN '1975-01-01' AND '1985-12-31' AND is_muggle=0;
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| id | firstname | lastname | birthday | birth_place | biography | is_muggle |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| 1 | harry | potter | 1980-07-31 | london | | 0 |
| 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
| 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
| 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
| 6 | fred | weasley | 1978-04-01 | | | 0 |
| 7 | george | weasley | 1978-04-01 |
@ChocW
ChocW / writeSecretSentence
Created April 8, 2019 08:39
le lion s'incline face au feu
<?php
function WriteSecretSentence( string $animal1, string $animal2): string
{
return $animal1 . " s'incline face au " . $animal2 ;
}
echo WriteSecretSentence("le loup", "lune") . "<br>";
echo WriteSecretSentence("le lion", "feu") . "<br>";
?>
@ChocW
ChocW / PHP Procédural
Created April 5, 2019 08:32
PHP Procédural - Les conditions
<?php
const BR = '<br/>';
//PHP Procédural - Les conditions
$weapons = ['fists', 'whip', 'gun'];
$opponentWeapon = $weapons[rand(0,2)];
// Cela permet de choisir une arme de manière aléatoire.
echo 'Opponent weapon: '.$opponentWeapon.'';
echo BR ;
@ChocW
ChocW / POO
Created April 3, 2019 07:47
quête POO
<?php
class Personne{
//créer les variables de la classe
private $nom;
private $prenom;
private $adresse;
private $dateDeNaissance;
@ChocW
ChocW / formulaire
Created April 1, 2019 07:29
questephp
<?php
//index.php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$errors = [];
//nom
// (!) pour la négation
if (!isset($_POST['nom']) || empty($_POST['nom']) )
@ChocW
ChocW / Challenge tableau&&boucles
Created March 26, 2019 15:46
tableau&&boucles
<?php
const BR = '<br/>';
$tableau1 = [
"Les Aventuriers de l'arche perdue"=>['Harrison Ford','Karen Allen', 'William Hootkins'],
"Indiana Jones et le Temple maudit"=>['Harrison Ford','Kate Capshaw', 'Jonathan Ke Quan'],
"Indiana Jones et la Dernière Croisade"=>['Harrison Ford','Sean Connery', 'Alison Doody'],
];
foreach ($tableau1 as $key => $value) {
@ChocW
ChocW / Challenge
Created March 25, 2019 09:26
Un message codé pour Indy
<?PHP
$msg1 = "0@sn9sirppa@#?ia'jgtvryko1";
$msg2 = "q8e?wsellecif@#?sel@#?setuotpazdsy0*b9+mw@x1vj";
$msg3 = "aopi?sgnirts@#?sedhtg+p9l!";
// msg1
// calcul le nombre de carac. et divise par 2.
$lenght = strlen($msg1)/2;
<?php
$nomFilmVO = 'Indiana Jones and the Last Crusade';
echo $nomFilmVO;
echo '<br/>';
$filmVuOuNon = false;
echo $filmVuOuNon;
echo '<br/>';