Ejemplo n.º 1
0
<?php

function generation($age)
{
    if ($age < 16) {
        echo "tu es un enfant";
    } elseif ($age == 18) {
        echo " bravo on va faire la fete";
    } elseif ($age > 18) {
        echo " tu es un adulte";
    } else {
        echo " euh c'est louche";
    }
}
echo generation(0);
echo "\n";
echo generation(15);
echo "\n";
echo generation(17);
echo "\n";
echo generation(18);
echo "\n";
echo generation(20);
echo "\n";
echo generation("simplon");
echo "\n";
echo generation(true);
echo "\n";
echo generation(array(1, 2));
Ejemplo n.º 2
0
    } elseif ($age < 18) {
        $resultat = "On y est presque";
    } elseif ($age == 18) {
        $resultat = "Tu es majeur ! Bravo !";
    } elseif ($age > 18) {
        $resultat = "Bonjour les adultes";
    } else {
        $resultat = "Vraiment louche";
    }
    return $resultat;
}
echo generation(0);
// enfant
echo generation(15);
// enfant
echo generation(16);
// enfant
echo generation(17);
// corrgié
echo generation(18);
// majeur
echo generation(19);
//adulte
echo generation("Simplon");
// enfant
echo generation(true);
// Enfant
echo generation(array(0, 1, 2));
// Adulte
echo "\n";
echo "\n";
Ejemplo n.º 3
0
<?php

function generation($age)
{
    if ($age < 18) {
        echo "t mineur";
    } else {
        echo "t majeur";
    }
}
echo generation($_GET["age"]);
// recupere la clé valeur sur le lien ?cle=valeur&cle2=valeur2
Ejemplo n.º 4
0
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            echo "id: " . $row["author_id"] . " - Name: " . $row["author_firstname"] . " " . $row["author_lastname"] . " - Email: " . $row["author_email"] . " - Affiliation: " . $row["author_affiliation"] . "<br>";
            //value assignment
            $fname = $row["author_firstname"];
            $lname = $row["author_lastname"];
            $org = $row["author_affiliation"];
            $email = $row["author_email"];
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    //generation
    $gen_code = generation($fname, $lname, $org, $email, $qrpng, $note);
    //display
    echo '<img src=' . $qrpng . ' />';
}
//see database
if (isset($_POST['listall'])) {
    $gen_code = 0;
    echo "<h2>Result:</h2>";
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = 'SELECT author_id, author_lastname, author_firstname, author_email, author_affiliation FROM author';
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
Ejemplo n.º 5
0
		}
	}
	echo generation(18);
	echo generation(15);
	echo generation(20);
	echo generation(false);
*/
function generation($age)
{
    $resultat = "Euh, c'est louche...\n";
    if ($age <= 17) {
        $resultat = "Tu es un enfant\n";
    } elseif ($age == 18) {
        $resultat = "Bravo, on peut faire la fête \n";
    } elseif ($age > 18) {
        $resultat = "Tu es un adulte\n";
    } else {
        $resultat = "Euh, c'est louche...\n";
    }
    return $resultat;
}
echo generation(18);
// Fête
echo generation(17);
// Enfant
echo generation(20);
// Adulte
echo generation(false);
// Enfant
echo generation(array(1, 2, 3));
// Adulte ???????