Example #1
0
function next_password($codes)
{
    $codes = increase($codes);
    while (!is_valid($codes)) {
        $codes = increase($codes);
    }
    return $codes;
}
function increase($i)
{
    $i += 2;
    if ($i <= 100) {
        echo $i - 1 . '<br />';
        echo $i . '<br />';
        increase($i);
    }
}
function increase($i)
{
    global $somecontent;
    $i += 2;
    if ($i <= 100) {
        $somecontent .= $i - 1 . "\r\n";
        $somecontent .= $i . "\r\n";
        increase($i);
    }
}
function summation()
{
    global $x;
    // global variable
    $y = 10;
    // local variable
    echo $x + $y . '<br>';
    echo $GLOBALS['x'] + $y . '<br>';
}
//summation();
//echo $x + $y;
/* Static Scope */
function increase($value)
{
    static $x = 1.9;
    $x = $value + $x;
    echo $x . '<br>';
}
function increase2($value)
{
    $x = 1.9;
    $x = $value + $x;
    echo $x . '<br>';
}
increase(0.2);
increase(4);
increase(1);
echo '<hr>';
increase2(0.2);
increase2(4);
increase2(1);
<?php

$inc = 4;
function increase($g)
{
    global $inc;
    //نمی توان در اینجا مقدار دهی اولیه داشت
    return $g + $inc;
}
echo increase(5);
//Output: 9
 /**
  * Get the balance increase percentage between the
  * month of a date and the previous month
  *
  * @param \DateTime $date
  * @return float|int
  */
 public function balanceIncrease(\DateTime $date)
 {
     return increase($this->currentBalance(), $this->balanceUntil($date));
 }
Example #7
0
        $digits[$base - 1] = $base - array_sum($digits);
        return TRUE;
    }
}
for ($base = 2; $base <= 36; $base++) {
    echo 'Base: ' . $base . ':' . PHP_EOL;
    $digits = array_fill(0, $base, 0);
    $digits[$base - 2] = 1;
    $digits[$base - 1] = $base - 1;
    $success = FALSE;
    do {
        $counts = array_fill(0, $base, 0);
        foreach ($digits as $digit) {
            $counts[$digit]++;
        }
        if ($digits == $counts) {
            $output = $digits;
            foreach ($output as $key => $value) {
                if ($value > 9) {
                    $output[$key] = chr($value - 10 + ord('A'));
                }
            }
            echo implode($output) . PHP_EOL;
            $success = TRUE;
        }
    } while (increase($digits));
    if (!$success) {
        echo 'No solutions.' . PHP_EOL;
    }
    echo PHP_EOL;
}