当前位置: 首页>>代码示例>>PHP>>正文


PHP g2函数代码示例

本文整理汇总了PHP中g2函数的典型用法代码示例。如果您正苦于以下问题:PHP g2函数的具体用法?PHP g2怎么用?PHP g2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了g2函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unset

    unset($gl);
    // unsets local "version" in current scope
    var_dump(isset($gl));
}
g1();
var_dump(isset($gl));
// still set
echo "---------- unsetting inside a function (\$GLOBALS) ------------\n";
function g2()
{
    var_dump(isset($GLOBALS['gl']));
    unset($GLOBALS['gl']);
    // unsets global "version"
    var_dump(isset($GLOBALS['gl']));
}
g2();
var_dump(isset($gl));
// no longer set
echo "---------- unsetting inside a function (pass-by-ref) ------------\n";
function g3($p1, &$p2)
{
    var_dump(isset($p1, $p2));
    unset($p1, $p2);
    // unsets local "version" in current scope
    var_dump(isset($p1, $p2));
}
$v1 = 10;
$v2 = 20;
g3($v1, $v2);
var_dump(isset($v1));
// still set
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:31,代码来源:intrinsics_unset.php

示例2: import

 static function import($task)
 {
     $start = microtime(true);
     g2_import::init();
     $stats = $task->get("stats");
     $done = $task->get("done");
     $total = $task->get("total");
     $completed = $task->get("completed");
     $mode = $task->get("mode");
     $queue = $task->get("queue");
     if (!isset($mode)) {
         $stats = g2_import::stats();
         $stats["items"] = $stats["photos"] + $stats["movies"];
         unset($stats["photos"]);
         unset($stats["movies"]);
         $stats["highlights"] = $stats["albums"];
         $task->set("stats", $stats);
         $task->set("total", $total = array_sum(array_values($stats)));
         $completed = 0;
         $mode = 0;
         $done = array();
         foreach (array_keys($stats) as $key) {
             $done[$key] = 0;
         }
         $task->set("done", $done);
         $root_g2_id = g2(GalleryCoreApi::getDefaultAlbumId());
         $root = ORM::factory("g2_map")->where("g2_id", "=", $root_g2_id)->find();
         if (!$root->loaded()) {
             $root->g2_id = $root_g2_id;
             $root->g3_id = 1;
             $root->save();
         }
     }
     $modes = array("groups", "users", "albums", "items", "comments", "tags", "highlights", "done");
     while (!$task->done && microtime(true) - $start < 1.5) {
         if ($done[$modes[$mode]] == $stats[$modes[$mode]]) {
             // Nothing left to do for this mode.  Advance.
             $mode++;
             $task->set("last_id", 0);
             $queue = array();
             // Start the loop from the beginning again.  This way if we get to a mode that requires no
             // actions (eg, if the G2 comments module isn't installed) we won't try to do any comments
             // queries.. in the next iteration we'll just skip over that mode.
             if ($modes[$mode] != "done") {
                 continue;
             }
         }
         switch ($modes[$mode]) {
             case "groups":
                 if (empty($queue)) {
                     $task->set("queue", $queue = array_keys(g2(GalleryCoreApi::fetchGroupNames())));
                 }
                 $log_message = g2_import::import_group($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing groups (%count of %total)", array("count" => $done["groups"] + 1, "total" => $stats["groups"]));
                 break;
             case "users":
                 if (empty($queue)) {
                     $task->set("queue", $queue = array_keys(g2(GalleryCoreApi::fetchUsersForGroup(GROUP_EVERYBODY))));
                 }
                 $log_message = g2_import::import_user($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing users (%count of %total)", array("count" => $done["users"] + 1, "total" => $stats["users"]));
                 break;
             case "albums":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2(GalleryCoreApi::fetchAlbumTree()));
                 }
                 $log_message = g2_import::import_album($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing albums (%count of %total)", array("count" => $done["albums"] + 1, "total" => $stats["albums"]));
                 break;
             case "items":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_item_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_item($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing photos (%count of %total)", array("count" => $done["items"] + 1, "total" => $stats["items"]));
                 break;
             case "comments":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_comment_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_comment($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing comments (%count of %total)", array("count" => $done["comments"] + 1, "total" => $stats["comments"]));
                 break;
//.........这里部分代码省略.........
开发者ID:viosca,项目名称:gallery3,代码行数:101,代码来源:g2_import_task.php

示例3: get_tag_item_ids

 /**
  * Get a set of comment ids from Gallery 2 greater than $min_id.  We use this to get the
  * next chunk of comments to import.
  */
 static function get_tag_item_ids($min_id)
 {
     global $gallery;
     $ids = array();
     $results = g2($gallery->search("SELECT DISTINCT([TagItemMap::itemId]) FROM [TagItemMap] " . "WHERE [TagItemMap::itemId] > ?", array($min_id), array("limit" => array("count" => 100))));
     while ($result = $results->nextResult()) {
         $ids[] = $result[0];
     }
     return $ids;
 }
开发者ID:hiwilson,项目名称:gallery3,代码行数:14,代码来源:g2_import.php

示例4: var_dump

    echo '$p ' . (isset($p) ? "is set\n" : "is not set\n");
    echo "g1 In:  \$p: {$p}\n";
    $p = 200;
    // actual argument's value changed
    echo "g1 Out: \$p: {$p}\n\n";
    return $p;
    // return by reference (can't use & here)
}
$a = 10;
var_dump($a);
$b =& g1($a);
// change $a from 10 to 200; make $b an alias to $a
var_dump($a);
var_dump($b);
$b = -12;
// change $a/$b
var_dump($a);
var_dump($b);
//*/
///*
function &g2()
{
    echo "g2 In:\n";
    $t = "local";
    return $t;
    // return byRef
}
$b =& g2();
// make $b an alias to the dynamic program location formerly aliased by local variable $t
var_dump($b);
//*/
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:byrefs.php

示例5: unset

unset($a);
// remove only alias from point, so destructor runs
echo "Done\n";
//*/
///*
echo "----------------- byRef returning of handle types ----------------------\n";
function &g2()
{
    $b = new Point(5, 7);
    // create first new point, and make $b an alias to it
    echo "After 'new Point(5, 7)', \$b is {$b}\n";
    return $b;
    // return as though using $a =& $b
    // as $b goes away, remove its alias
}
$a = g2();
echo "After '\$a = f2()', \$a is {$a}\n";
unset($a);
// remove only alias from point, so destructor runs
echo "Done\n";
//*/
echo "----------------- unsetting properties ----------------------\n";
class C
{
    public $prop1;
    public $prop2;
    public function __destruct()
    {
        echo "\nInside " . __METHOD__ . "\n\n";
    }
}
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:31,代码来源:memory_model_and_handle_types.php

示例6: arc

function arc($x, $y, $x1, $y1, $x2, $y2, $z)
{
    g0(_, _, SAFE_Z);
    g0($x1, $y1, _);
    if (!is_array($z)) {
        $z = array($z);
    }
    $g2 = true;
    foreach ($z as $zz) {
        g1(_, _, $zz);
        if ($g2) {
            g2($x2, $y2, _, $x - $x1, $y - $y1, _);
        } else {
            g3($x1, $y1, _, $x - $x2, $y - $y2, _);
        }
        $g2 = !$g2;
    }
    g0(_, _, SAFE_Z);
}
开发者ID:samw3,项目名称:phfab,代码行数:19,代码来源:gcode.php

示例7: get_group_ids

 /**
  * Get a set of group ids from Gallery 2 greater than $min_id.  We use this to get the
  * next chunk of groups to import.
  */
 static function get_group_ids($min_id)
 {
     global $gallery;
     $ids = array();
     $results = g2($gallery->search("SELECT [GalleryGroup::id] " . "FROM [GalleryGroup] " . "WHERE [GalleryGroup::id] > ? " . "ORDER BY [GalleryGroup::id] ASC", array($min_id), array("limit" => array("count" => 100))));
     while ($result = $results->nextResult()) {
         $ids[] = $result[0];
     }
     return $ids;
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:14,代码来源:g2_import.php

示例8: import

 static function import($task)
 {
     g2_import::lower_error_reporting();
     $start = microtime(true);
     g2_import::init();
     $stats = $task->get("stats");
     $done = $task->get("done");
     $total = $task->get("total");
     $completed = $task->get("completed");
     $mode = $task->get("mode");
     $queue = $task->get("queue");
     if (!isset($mode)) {
         $stats = g2_import::g2_stats();
         $stats["items"] = $stats["photos"] + $stats["movies"];
         unset($stats["photos"]);
         unset($stats["movies"]);
         $stats["highlights"] = $stats["albums"];
         $task->set("stats", $stats);
         $task->set("total", $total = array_sum(array_values($stats)));
         $completed = 0;
         $mode = 0;
         $done = array();
         foreach (array_keys($stats) as $key) {
             $done[$key] = 0;
         }
         $task->set("done", $done);
         // Ensure G2 ACLs are compacted to speed up import.
         g2(GalleryCoreApi::compactAccessLists());
     }
     $modes = array("groups", "users", "albums", "items", "comments", "tags", "highlights", "done");
     while (!$task->done && microtime(true) - $start < 1.5) {
         if ($done[$modes[$mode]] == $stats[$modes[$mode]]) {
             // Nothing left to do for this mode.  Advance.
             $mode++;
             $task->set("last_id", 0);
             $queue = array();
             // Start the loop from the beginning again.  This way if we get to a mode that requires no
             // actions (eg, if the G2 comments module isn't installed) we won't try to do any comments
             // queries.. in the next iteration we'll just skip over that mode.
             if ($modes[$mode] != "done") {
                 continue;
             }
         }
         switch ($modes[$mode]) {
             case "groups":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_group_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_group($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing groups (%count of %total)", array("count" => $done["groups"] + 1, "total" => $stats["groups"]));
                 break;
             case "users":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_user_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_user($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing users (%count of %total)", array("count" => $done["users"] + 1, "total" => $stats["users"]));
                 break;
             case "albums":
                 if (empty($queue)) {
                     $g2_root_id = g2(GalleryCoreApi::getDefaultAlbumId());
                     $tree = g2(GalleryCoreApi::fetchAlbumTree());
                     $task->set("queue", $queue = array($g2_root_id => $tree));
                     // Update the root album to reflect the Gallery2 root album.
                     $root_album = item::root();
                     g2_import::set_album_values($root_album, g2(GalleryCoreApi::loadEntitiesById($g2_root_id)));
                     $root_album->save();
                 }
                 $log_message = g2_import::import_album($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing albums (%count of %total)", array("count" => $done["albums"] + 1, "total" => $stats["albums"]));
                 break;
             case "items":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_item_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_item($queue);
                 if ($log_message) {
                     $task->log($log_message);
                 }
                 $task->status = t("Importing photos (%count of %total)", array("count" => $done["items"] + 1, "total" => $stats["items"]));
                 break;
             case "comments":
                 if (empty($queue)) {
                     $task->set("queue", $queue = g2_import::get_comment_ids($task->get("last_id", 0)));
                     $task->set("last_id", end($queue));
                 }
                 $log_message = g2_import::import_comment($queue);
                 if ($log_message) {
//.........这里部分代码省略.........
开发者ID:JasonWiki,项目名称:docs,代码行数:101,代码来源:g2_import_task.php

示例9: g1

<?php

function g1()
{
    (yield 2);
    (yield 3);
    return 42;
}
function g2()
{
    (yield 1);
    $g1result = (yield from g1());
    (yield 4);
    return $g1result;
}
$g = g2();
foreach ($g as $yielded) {
    var_dump($yielded);
}
var_dump($g->getReturn());
开发者ID:badlamer,项目名称:hhvm,代码行数:20,代码来源:yield_from_expression_value.php

示例10: g2

<?php

function g2()
{
    $arr = array(0, 1, 2, 3);
    $b = true;
    foreach ($arr as &$v) {
        (yield null);
        echo "val={$v}\n";
        if ($b && $v == 1) {
            $b = false;
            $old = $arr;
            $arr = array(4, 5, 6, 7);
        } else {
            if ($v == 6) {
                $arr = $old;
                unset($old);
            }
        }
    }
}
foreach (g2() as $_) {
}
开发者ID:badlamer,项目名称:hhvm,代码行数:23,代码来源:468.php


注:本文中的g2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。