function ethiopicmult($plier, $plicand, $tutor)
{
    if ($tutor) {
        echo "ethiopic multiplication of {$plier} and {$plicand}\n";
    }
    $r = 0;
    while ($plier >= 1) {
        if (!iseven($plier)) {
            $r += $plicand;
        }
        if ($tutor) {
            echo "{$plier}, {$plicand} ", iseven($plier) ? "struck" : "kept", "\n";
        }
        $plier = halve($plier);
        $plicand = double($plicand);
    }
    return $r;
}
Example #2
0
function htmlekle2($id)
{
    // bunun tek farki echo yapmaz. return eder.
    $id = trim($id);
    if ($id == "") {
        return "id bo verilmi. (htmlekle2)";
    }
    if (kayitsayisi("html", "id='{$id}'") == 0) {
        return "({$id}) id'li kod bulunamadi. eklemek icin <a href=/kafe/admin/htmlkodekle.php?id={$id}>buraya tiklayiniz</a> ";
    }
    global $nestcount;
    $nestcount++;
    if ($nestcount > 100) {
        echo "<hr>C*k fazla icice dongu(nest) var.(100 adet)";
        exit;
    }
    $query = "select * from html where id='{$id}'";
    $kod = dbresult($query, array("htmlkodu"));
    //$kod="<kodadi=$id>".$kod."</kodadi=$id>";
    $parcalar = explode("{kod}", $kod[0]);
    $sayi = count($parcalar);
    $out = "";
    $out .= "\n<kodadi={$id}>";
    for ($i = 0; $i < $sayi; $i++) {
        if (iseven($i)) {
            $out .= $parcalar[$i];
        } else {
            $out .= htmlekle2($parcalar[$i]);
        }
    }
    $nestcount--;
    $out .= "</kodadi={$id}>";
    return $out;
}
Example #3
0
 function htmlekle2($id)
 {
     # bunun tek farki echo yapmaz. return eder.
     $id = trim($id);
     if ($id == '') {
         return "id empty. (htmlekle2)";
     }
     if ($this->recordcount("html", "id='{$id}'") == 0) {
         return "({$id}) id'li kod not found. <br>" . $this->sayinmylang('perhaps_db_error');
     }
     global $nestcount;
     $nestcount++;
     if ($nestcount > 100) {
         echo "<hr>too many nestcount (100, htmlekle2)";
         $this->showexit();
     }
     #$query="select * from html where id='$id'";
     $kod = $this->getField('html', 'htmlkodu', "id='{$id}'");
     #$kod=dbresult($query,array("htmlkodu"));
     #$kod="<kodadi=$id>".$kod."</kodadi=$id>";
     $parcalar = explode("{kod}", $kod);
     $sayi = count($parcalar);
     $out = '';
     $out .= "\n<kodadi={$id}>";
     for ($i = 0; $i < $sayi; $i++) {
         if (iseven($i)) {
             $out .= $parcalar[$i];
         } else {
             $out .= $this->htmlekle2($parcalar[$i]);
         }
     }
     $nestcount--;
     $out .= "</kodadi={$id}>";
     return $out;
 }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Oplossing Functions
: Deel 1</title>
    <link rel="stylesheet" href="http://web-backend.local/css/global.css">
    <link rel="stylesheet" href="http://web-backend.local/css/facade.css">
    <link rel="stylesheet" href="http://web-backend.local/css/directory.css">
</head>
    <body>
    <p>
        <?php 
echo "De som van 4+5 = " . berekenSom(4, 5);
?>
    </p>
    <p>
        <?php 
echo "het product van 4x5 = " . vermenigvuldig(4, 5);
?>
    </p>
    <p> het getal 4 is
       <?php 
echo iseven(4) ? "even" : "oneven";
?>
    </p>
    
    </body>
</html>