コード例 #1
0
ファイル: api.php プロジェクト: maxencebeno/androidlpmetinet
 */
$method = $_SERVER['REQUEST_METHOD'];
/**
 * Application du verbe sur la ressource
 */
switch ($method) {
    case 'GET':
        if (isset($_GET['action']) && $_GET['action'] == "all") {
            try {
                getVilles();
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        } else {
            try {
                getVille();
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
        break;
    case 'DELETE':
        deleteVille();
        break;
    case 'PUT':
        updateVille();
        break;
    case 'POST':
        createVille();
        break;
    default:
コード例 #2
0
ファイル: say-my-name.php プロジェクト: Scratchy35/Demo-php
<?php

if (isset($_POST['monNom']) && !empty($_POST['monNom'])) {
    echo getNom($_POST['monNom']);
}
if (isset($_POST['monCp']) && !empty($_POST['monCp'])) {
    echo getVille($_POST['monCp']);
}
function getNom($monNom)
{
    $htmlMonNom = "Bonjour <span id='monNom'>{$monNom}</span>";
    $reponse = "";
    switch ($monNom) {
        case "Luigi":
            $reponse = ", je te connais tu es le frère de Mario";
            break;
        case "Mario":
            $reponse = ", je te connais tu es le frère de Luigi";
            break;
        case "Père noel":
            $reponse = ", Joyeux noël et bonne année";
            break;
        default:
            $reponse = ", Désolée mais je ne te connais pas";
    }
    return "<div id='bonjour'>{$htmlMonNom} {$reponse}</div>";
}
function getVille($monCp)
{
    header('Content-Type: application/json');
    return trouverVilleIlleEtVilaine($monCp);