本文整理汇总了PHP中console函数的典型用法代码示例。如果您正苦于以下问题:PHP console函数的具体用法?PHP console怎么用?PHP console使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了console函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPHPLocation
function findPHPLocation($windows = false)
{
$phpLocation = '';
if ($windows) {
console('Trying to find the location of php.exe');
// Search in current dir first.
$exp = explode("\r\n", shell_exec('dir /s /b php.exe'));
if (preg_match('/^.*\\\\php\\.exe$/', $exp[0])) {
$phpLocation = $exp[0];
} else {
// Do a recursive search on this whole drive.
chdir('/');
$exp = explode("\r\n", shell_exec('dir /s /b php.exe'));
if (preg_match('/^.*\\\\php\\.exe$/', $exp[0])) {
$phpLocation = $exp[0];
}
chdir(ROOTPATH);
}
} else {
$exp = explode(' ', shell_exec('whereis php'));
$count = count($exp);
if ($count == 1) {
// Some *nix's output is only the path
$phpLocation = $exp[0];
} else {
if ($count > 1) {
// FreeBSD for example has more info on the line, like :
$phpLocation = $exp[1];
}
}
// php: /user/local/bin/php /usr/local/man/man1/php.1.gz
}
return $phpLocation;
}
示例2: commandH
public function commandH($cmd, $params, $issuer, $alias)
{
$output = "";
$this->path = $this->api->plugin->createConfig($this, array(array()));
console("Map to update");
$map = array(array());
$level = $this->api->level->getDefault();
for ($x = 0; $x <= 256; $x++) {
console($x);
for ($z = 0; $z <= 256; $z++) {
//console("($x, $z)");
for ($y = 127; $y >= 0; $y--) {
$pos = new Vector3($x, $y, $z);
$id = (int) $level->getBlock($pos)->getID();
if (!in_array($id, array(AIR, TORCH, SIGN_POST, WALL_SIGN))) {
//console("$x,$z,$y:$id");
$map[$x][$z] = $id;
break;
}
}
}
}
console("Map write update");
$this->api->plugin->writeYAML($this->path . "config.yml", $map);
$output .= "Map updated";
return $output;
}
示例3: init
public function init()
{
$this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array("ownerName" => "", "externalAddress" => "", "externalPort" => ""));
$error = 0;
if ($this->config->get("ownerName") == "") {
console("[ERROR] [Realms] Please set your ownerName to your Realms name.");
++$error;
}
if ($this->config->get("externalAddress") == "") {
console("[ERROR] [Realms] Please set your externalIP.");
++$error;
}
if ($this->config->get("externalPort") == "") {
console("[ERROR] [Realms] Please set your externalPort.");
++$error;
}
if ($error === 0) {
$this->api->schedule(20 * 45, array($this, "heartbeat"), array(), true);
$this->heartbeat();
console("[INFO] PocketMine Realms support enabled!");
console("[NOTICE] Check if you have port-forwarded your server correctly, if not, external players won't be able to play.");
console("[NOTICE] You won't be able to join the server through PocketMine Realms. Join it on the Play menu (like Local servers).");
} else {
console("[ERROR] PocketMine Realms not enabled. Please configure the plugin properly.");
}
}
示例4: eventHandler
public function eventHandler($data, $event)
{
console($data['query']);
$this->db->multi_query($data['query']);
if ($this->db->more_results()) {
do {
} while ($this->db->next_result());
}
}
示例5: onReorder
public function onReorder(IS_REO $REO)
{
$this->reorder = FALSE;
# As we are copying LFS REO state, we don't need to send this packet on TINY_VTA packet.
foreach ($REO->PLID as $Pos => $PLID) {
console(sprintf("Pos: %02d | PLID: %02d | UName: %24s | PName: %24s", $Pos, $PLID, $this->getClientByPLID($PLID)->UName, $this->getPlayerByPLID($PLID)->PName));
}
$this->IS_REO->NumP(count($REO->PLID))->PLID($REO->PLID);
# Updates our list.
return PLUGIN_CONTINUE;
}
示例6: resultAction
public function resultAction()
{
$this->view->setVar('siteTitle', '会员管理');
$this->view->disable(1);
$arr = \MagicCategory::find();
// $arr->toArray();
foreach ($arr->toArray() as $key => $val) {
echo $val['category_name'];
}
console($arr->toArray());
}
示例7: init
public function init()
{
$this->api->addHandler("player.move", array($this, "handler"), 1);
$this->api->addHandler("player.quit", array($this, "handler"), 1);
$this->api->addHandler("player.block.break", array($this, "handler"), 20);
$this->api->addHandler("player.block.break.invalid", array($this, "handler"), 20);
$this->api->addHandler("player.block.place.invalid", array($this, "handler"), 20);
$this->api->console->register("magiccarpet", "[size]", array($this, "command"));
$this->api->console->alias("mc", "magiccarpet");
//$this->api->ban->cmdWhitelist("magiccarpet");
console("[INFO] MagicCarpet enabled! Use /mc to toggle it");
}
示例8: run
/**
* Runs the while loop, wait for connections and handle them
*/
private function run()
{
while (true) {
# because socket_select gets the sockets it should watch from $changed_sockets
# and writes the changed sockets to that array we have to copy the allsocket array
# to keep our connected sockets list
$changed_sockets = $this->allsockets;
# blocks execution until data is received from any socket
$num_sockets = socket_select($changed_sockets, $write = NULL, $exceptions = NULL, NULL);
# foreach changed socket...
foreach ($changed_sockets as $socket) {
# master socket changed means there is a new socket request
if ($socket == $this->master) {
# if accepting new socket fails
if (($client = socket_accept($this->master)) < 0) {
console('socket_accept() failed: reason: ' . socket_strerror(socket_last_error($client)));
continue;
} else {
$this->allsockets[] = $client;
# using array key from allsockets array, is that ok?
# i want to avoid the often array_search calls
$socket_index = array_search($client, $this->allsockets);
$this->clients[$socket_index] = new stdClass();
$this->clients[$socket_index]->socket_id = $client;
$this->console($client . ' CONNECTED!');
}
} else {
$socket_index = array_search($socket, $this->allsockets);
# the client status changed, but theres no data ---> disconnect
$bytes = @socket_recv($socket, $buffer, 2048, 0);
if ($bytes === 0) {
$this->disconnected($socket);
} else {
# this is a new connection, no handshake yet
if (!isset($this->handshakes[$socket_index])) {
$this->do_handshake($buffer, $socket, $socket_index);
} else {
$action = substr($buffer, 1, $bytes - 2);
// remove chr(0) and chr(255)
$this->console("<{$action}");
if (method_exists('socketWebSocketTrigger', $action)) {
$this->send($socket, socketWebSocketTrigger::$action());
} else {
for ($i = 0; $i <= 0; $i++) {
$this->send($socket, "{$action}");
}
}
}
}
}
}
}
}
示例9: status
function status($msg)
{
if (true) {
console(trim($msg));
return;
}
global $statusPadding;
clearLine();
echo $msg;
echo "\r";
$statusPadding = strlen($msg);
}
示例10: convert
public function convert()
{
$path = $this->api->plugin->configPath($this);
console($path);
$path = str_replace("SimpleAuth", "ResidentManager", $path);
console($path);
$cfg = $this->api->plugin->readYAML($path . "config.yml");
foreach ($cfg as $key => $value) {
$data = array("registerdate" => time() - 1000000, "logindate" => $value['last'], "hash" => $value['password']);
$this->playerFile->set($key, $data);
$this->playerFile->save();
}
}
示例11: commandH
public function commandH($cmd, $params, $issuer, $alias)
{
console($params[0]);
$output = '';
$players = $this->api->player->getAll();
$gms = array("0" => SURVIVAL, "survival" => SURVIVAL, "s" => SURVIVAL, "1" => CREATIVE, "creative" => CREATIVE, "c" => CREATIVE, "2" => ADVENTURE, "adventure" => ADVENTURE, "a" => ADVENTURE, "3" => VIEW, "view" => VIEW, "viewer" => VIEW, "spectator" => VIEW, "v" => VIEW);
$this->config = $gms[strtolower($params[0])];
$this->api->plugin->writeYAML($this->path . "config.yml", $this->config);
$output .= "Default gamemode changed to {$this->config}";
$players = $this->api->player->getAll();
foreach ($players as $player) {
$player->{$player}->setGamemode($this->config);
}
return $output;
}
示例12: abandonedMineShaft
public function abandonedMineShaft(&$output)
{
console("Generating...(It takes about 1~5 minutes)");
$this->fork = array();
$crd = $this->setCenter();
if ($crd === false) {
console("Failed to generate: couldn't set center point.");
}
$this->min = array(10, $crd[1] - 10, 10);
$this->max = array(245, $crd[1] + 10, 245);
console("Seted center point to (" . $crd[0] . ", " . $crd[1] . ", " . $crd[2] . ")");
$this->gFork($crd[0], $crd[1], $crd[2]);
console("Finished!! (" . $this->count . " forks)");
$this->fork = array();
}
示例13: init
public function init()
{
$this->api->console->register("simpleworlds", "<command> [parameters...]", array($this, "command"));
$this->api->console->alias("sw", "simpleworlds");
$this->api->console->alias("swe", "simpleworlds export");
$this->api->console->alias("swu", "simpleworlds unload");
$this->api->console->alias("swl", "simpleworlds load");
$this->api->console->alias("swg", "simpleworlds generate");
$this->api->console->alias("swls", "simpleworlds list");
$this->api->console->alias("swd", "simpleworlds delete");
$this->config = new Config($this->api->plugin->configPath($this) . "config.yml", CONFIG_YAML, array("default-generator" => "SuperflatGenerator", "autogenerate" => false, "autoload" => array()));
console("[SimpleWorlds] Loading levels...");
foreach ($this->config->get("autoload") as $level) {
$this->loadLevel($level);
}
}
示例14: check
public function check()
{
for ($n = 0; $n < $this->threads; ++$n) {
if ($this->workers[$n]->isTerminated() === true) {
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
} elseif ($this->workers[$n]->isWaiting()) {
if ($this->workers[$n]->response !== "") {
console($this->workers[$n]->response);
$this->workers[$n]->notify();
} else {
$this->workers[$n]->response = ServerAPI::request()->api->console->run($this->workers[$n]->cmd, "rcon");
$this->workers[$n]->notify();
}
}
}
}
示例15: initialise
public function initialise()
{
global $PRISM;
if ($this->loadIniFile($this->cvars, FALSE)) {
if ($this->cvars['debugMode'] & PRISM_DEBUG_CORE) {
console('Loaded ' . $this->iniFile);
}
} else {
$this->cvars['secToken'] = str_replace(array('"', '\'', ' '), '.', createRandomString(16));
console('Using cvars defaults.');
if ($this->createIniFile('PHPInSimMod Configuration Variables', array('prism' => &$this->cvars))) {
console('Generated config/' . $this->iniFile);
}
}
return true;
}