function third() { enter_function('third'); second(); first(); exit_function(); }
function first() { var_dump(__FUNCTION__ . ' - ' . 1); yield from delay(1000); var_dump(__FUNCTION__ . ' - ' . 2); yield from delay(1000); yield from second(); return 5; }
function first($arg1, $arg2) { second(TRUE, FALSE); }
echo "Hello World"; } first(); ?> <br /> <br /> <p>Function With Variable </p> <?php function second($var) { echo "Hello {$var} <br>"; } $t = "everybody"; // we pass the variable $t in to the function second($t); second("gg"); ?> <br /> <p>function with return </p> <?php function third($var) { $hello = "Hello {$var} <br>"; return $hello; } // the function dose't print any thing, // so we add the function in to variable and then print the variable $new_var = third("everybody"); echo $new_var; ?> <br />
/** * Returns the result of applying concat to the result of mapping f over colls */ function mapcat() { $args = func_get_args(); return apply('v\\concat', map(first($args), second($args))); }
<?php // install.php :: creates/populates database tables on a new installation. include 'lib.php'; $link = opendb(); $start = getmicrotime(); if (isset($_GET["page"])) { $page = $_GET["page"]; if ($page == 2) { second(); } elseif ($page == 3) { third(); } elseif ($page == 4) { fourth(); } elseif ($page == 5) { fifth(); } else { first(); } } else { first(); } // Thanks to Predrag Supurovic from php.net for this function! function dobatch($p_query) { $query_split = preg_split("/[;]+/", $p_query); foreach ($query_split as $command_line) { $command_line = trim($command_line); if ($command_line != '') { $query_result = mysql_query($command_line); if ($query_result == 0) {
public static function generateStreamIDHash($url, $deterministic) { // For load balancing purposes, the hash should be spread as randomly // as possible. if ($deterministic) { // randomize deterministically: $randomize = self::createHash($url); } else { // randomize based on current time: $randomize(hour(now) & minute(now) & second(now)); } $streamidhash = 0; srand(); // generate random serial number between 0 and 15 $streamidhash = rand(0, 15); //echo "DEBUG: Raw streamidhash is $streamidhash\n"; $streamidhash = dechex($streamidhash); return $streamidhash; }
<?php function first($item) { return $item; } function second($item, $item2) { // global $name; // echo $name; echo $item, $item2; } $name = 'Sergey'; $secondName = 'Lunev'; second(first('Hello'), $secondName); echo "<br>"; echo "<br>"; echo "<br>"; const NAME = "Sergey"; define('SURNAME', 'Lunev'); echo NAME; echo "<br>"; echo "<br>"; echo "<br>"; echo SURNAME;
function format_Time($timeStr, $nType) { $y = ''; $m = ''; $d = ''; $h = ''; $mi = ''; $s = ''; $format_Time = ''; if (isDate($timeStr) == false) { return @$format_Time; } $y = cStr(year($timeStr)); $m = cStr(month($timeStr)); if (len($m) == 1) { $m = '0' . $m; } $d = cStr(day($timeStr)); //在vb.net里要这样用 D = CStr(CDate(timeStr).Day) if (len($d) == 1) { $d = '0' . $d; } $h = cStr(hour($timeStr)); if (len($h) == 1) { $h = '0' . $h; } $mi = cStr(minute($timeStr)); if (len($mi) == 1) { $mi = '0' . $mi; } $s = cStr(second($timeStr)); if (len($s) == 1) { $s = '0' . $s; } switch ($nType) { case 1: //yyyy-mm-dd hh:mm:ss $format_Time = $y . '-' . $m . '-' . $d . ' ' . $h . ':' . $mi . ':' . $s; break; case 2: //yyyy-mm-dd $format_Time = $y . '-' . $m . '-' . $d; break; case 3: //hh:mm:ss $format_Time = $h . ':' . $mi . ':' . $s; break; case 4: //yyyy年mm月dd日 $format_Time = $y . '年' . $m . '月' . $d . '日'; break; case 5: //yyyymmdd $format_Time = $y . $m . $d; break; case 6: //yyyymmddhhmmss $format_Time = $y . $m . $d . $h . $mi . $s; break; case 7: //mm-dd $format_Time = $m . '-' . $d; break; case 8: //yyyy年mm月dd日 $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . ':' . $mi . ':' . $s; break; case 9: //yyyy年mm月dd日H时mi分S秒 早上 $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分' . $s . '秒,' . getDayStatus($h, 1); break; case 10: //yyyy年mm月dd日H时 $format_Time = $y . '年' . $m . '月' . $d . '日' . $h . '时'; break; case 11: //yyyy年mm月dd日H时mi分S秒 $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分' . $s . '秒'; break; case 12: //yyyy年mm月dd日H时mi分 $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分'; break; case 13: //yyyy年mm月dd日H时mi分 早上 $format_Time = $m . '月' . $d . '日' . ' ' . $h . ':' . $mi . ' ' . getDayStatus($h, 0); break; case 14: //yyyy年mm月dd日 $format_Time = $y . '/' . $m . '/' . $d; break; case 15: //yyyy年mm月 第1周 $format_Time = $y . '年' . $m . '月 第' . GetCountPage($d, 7) . '周'; } return @$format_Time; }