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


PHP xp_import函数代码示例

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


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

示例1: dirname

<?php

/**
 * Copyright 2010-12 Nickolas Whiting. All rights reserved.
 * Use of this source code is governed by the Apache 2 license
 * that can be found in the LICENSE file.
 */
require_once dirname(realpath(__FILE__)) . '/../__init__.php';
xp_import('unittest');
xp_import('time');
unittest\test(function ($test) {
    $processor = new \XPSPL\Processor();
    $start = time();
    $processor->signal(new \time\SIG_Awake(1, TIME_SECONDS), new \XPSPL\Process(function () use($start, $test) {
        $test->equal(1, time() - $start);
    }, 1));
    $processor->wait_loop();
}, 'Time Module');
开发者ID:prggmr,项目名称:xpspl,代码行数:18,代码来源:time.php

示例2: xp_import

<?php

/**
 * Copyright 2010-12 Nickolas Whiting. All rights reserved.
 * Use of this source code is governed by the Apache 2 license
 * that can be found in the LICENSE file.
 */
require_once '__init__.php';
xp_import('unittest');
unittest\test(function ($test) {
    $db = new \XPSPL\database\Processes();
    $p1 = new \XPSPL\Process(null);
    $p2 = xp_high_priority(new \XPSPL\Process(null));
    $db->install($p1);
    $db->install($p2);
    $db->delete($p1);
    $test->equal($db->count(), 1);
    $test->equal($db->current()->get_priority(), 0);
}, "process delete");
开发者ID:prggmr,项目名称:xpspl,代码行数:19,代码来源:process_delete.php

示例3: xp_import

<?php

namespace network;

/**
 * Copyright 2010-12 Nickolas Whiting. All rights reserved.
 * Use of this source code is governed by the Apache 2 license
 * that can be found in the LICENSE file.
 */
xp_import('logger');
use XPSPL\idle\Process, XPSPL\idle\Time;
/**
 * Socket
 *
 * Event driven I/O.
 */
class Socket extends \XPSPL\SIG_Routine
{
    /**
     * Socket connection object
     *
     * @var  object
     */
    protected $_connection = null;
    /**
     * Socket Address
     *
     * @var  string
     */
    protected $_address = null;
    /**
开发者ID:prggmr,项目名称:xpspl,代码行数:31,代码来源:socket.php

示例4: round

                            $lines++;
                        }
                        if ($_v >= 1) {
                            $total++;
                        }
                    }
                    $avg[$file] = round($total / $lines * 100, 2);
                } else {
                    $avg[$file] = 0;
                }
            }, $_file);
        }
        $total = 0.0;
        foreach ($avg as $_c) {
            $total += $_c;
        }
        \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true);
        \unittest\Output::send(sprintf('Total Test Coverage : %s%%', round($total / (count($avg) * 100) * 100, 2)), \unittest\Output::DEBUG, true);
        \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true);
        foreach ($avg as $_k => $_c) {
            \unittest\Output::send(sprintf('File : %s', $_k), \unittest\Output::DEBUG, true);
            \unittest\Output::send(sprintf('Coverage : %s%%', $_c), \unittest\Output::DEBUG, true);
            \unittest\Output::send('--------------------', \unittest\Output::DEBUG, true);
        }
    });
}
xp_import("unittest");
// load the standard unittest output
unittest\generate_output();
// make sure we save the event history
xp_set_signal_history(true);
开发者ID:prggmr,项目名称:xpspl,代码行数:31,代码来源:__init__.php

示例5: xp_import

<?php

xp_import('time');
xp_import('ftp');
// Must provide username/password
$connection = ['hostname' => 'ftps://app.brickftp.com', 'username' => '-', 'password' => '-', 'secure' => false];
$files = [dirname(realpath(__FILE__)) . '/file_1.txt', dirname(realpath(__FILE__)) . '/file_2.txt', dirname(realpath(__FILE__)) . '/file_3.txt', dirname(realpath(__FILE__)) . '/file_4.txt'];
$uploader = ftp\upload($files, $connection, function ($signal) {
    echo "Upload Started" . PHP_EOL;
});
ftp\complete($uploader, function ($signal) {
    echo $signal->get_file()->get_name() . ' uploaded succesfully' . PHP_EOL;
});
ftp\failure($uploader, function ($signal) {
    echo $signal->get_file()->get_name() . ' failed to upload' . PHP_EOL;
});
开发者ID:prggmr,项目名称:xpspl,代码行数:16,代码来源:upload.php

示例6: xp_import

<?php

/**
 * Copyright 2010-12 Nickolas Whiting. All rights reserved.
 * Use of this source code is governed by the Apache 2 license
 * that can be found in the LICENSE file.
 */
/**
 * Chat Server
 *
 * This example demonstrates how to build a simple TCP chat server which can
 * be connected using telnet.
 */
xp_import('network');
$socket = network\connect('0.0.0.0', ['port' => '8000'], function () {
    echo "Server Running on " . $this->socket->get_address() . PHP_EOL;
});
$socket->on_connect(function (network\SIG_Connect $sig_connect) use($socket) {
    $sig_connect->socket->write("Welcome to the prggmr chat server" . PHP_EOL);
    $sig_connect->socket->write("Enter your username : ");
});
$socket->on_read(null);
$socket->on_read(function (network\SIG_Read $sig_read) use($socket) {
    $clients = $socket->get_connections();
    $client = $clients[intval($sig_read->socket->get_resource())];
    // Strip any newlines from linux
    $sig_read->socket->_read_buffer();
    $content = implode("", explode("\r\n", $sig_read->socket->read()));
    // windows
    $content = implode("", explode("\n\r", $content));
    // On first connection read in the username
开发者ID:prggmr,项目名称:xpspl,代码行数:31,代码来源:chat_server.php


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