本文整理汇总了PHP中Console::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::write方法的具体用法?PHP Console::write怎么用?PHP Console::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: input
public static function input($prompt, $color = null)
{
Console::write($prompt, $color);
$finput = fopen("php://stdin", "r");
$input = fgets($finput);
return str_replace("\n", "", $input);
}
示例2: sprawdzCzyKoniec
/**
* Sprawdza czy pobrany obiektma parametr życie mniejszy bądź równy 0
* @return boolean
*/
public function sprawdzCzyKoniec()
{
if ($this->gracz->Getparam()->getZycie() <= 0) {
Console::write("Koniec gry");
return false;
} elseif ($this->przeciwnik->Getparam()->getZycie() <= 0) {
Console::write("Koniec gry wygrales!!!");
return false;
}
return true;
}
示例3: start
/**
* Obsługa głównego wątku gry
*/
public function start()
{
$tura = new Tura();
Console::write($this->tekst(1));
$tura->dodajGracza(new Postac\Wiedzmin($this->getsession('result')));
$tura->dodajPrzeciwnika(new Postac\Potwor($this->getsession('result')));
do {
Console::write($this->tekst(3));
$tura->aktywne();
$x = Console::read();
$tura->akcja($x);
} while ($tura->sprawdzCzyKoniec());
}
示例4: extract
/**
* Extract a ".ar" file into a given target directory
*
* @param string base
* @param string ar
* @param io.Folder target
* @throws lang.IllegalStateException in case the target is not found
* @throws lang.FormatException in case the .ar-file is not parseable
*/
protected function extract($base, $ar, Folder $target)
{
// Open a HTTP connection
$url = new URL($base . $ar . '.ar');
$r = create(new HttpConnection($url))->get();
if (HttpConstants::STATUS_OK != $r->getStatusCode()) {
throw new IllegalStateException(sprintf('Unexpected response %d:%s for %s', $r->getStatusCode(), $r->getMessage(), $url->getURL()));
}
$in = new BufferedInputStream($r->getInputStream());
do {
// Seach for first section header, --[LENGTH]:[FILENAME]-- and parse it
do {
$line = $this->readLine($in);
if (!$in->available()) {
throw new FormatException('Cannot locate section header');
}
} while (2 !== sscanf($line, '--%d:%[^:]--', $length, $filename));
// Calculate target file
$file = new File($target, $filename);
$folder = new Folder($file->getPath());
$folder->exists() || $folder->create();
Console::writef(' >> [%-10s] %s (%.2f kB) [%s]%s', $ar, $filename, $length / 1024, str_repeat('.', self::PROGRESS_INDICATOR_WIDTH), str_repeat("", self::PROGRESS_INDICATOR_WIDTH + 1));
// Transfer length bytes into file
$c = 0;
$out = $file->getOutputStream();
$size = 0;
while ($size < $length) {
$chunk = $in->read(min(0x1000, $length - $size));
$size += strlen($chunk);
$out->write($chunk);
// Update progress
$d = ceil($size / $length * self::PROGRESS_INDICATOR_WIDTH);
if ($d == $c) {
continue;
}
Console::write(str_repeat('#', $d - $c));
$c = $d;
}
$out->close();
Console::writeLine();
} while ($in->available() > 0);
$in->close();
}
示例5: exceptionFromToString
public function exceptionFromToString()
{
try {
Console::write(newinstance('lang.Object', array(), '{
public function toString() { throw new IllegalStateException("Cannot render string"); }
}'));
$this->fail('Expected exception not thrown', NULL, 'lang.IllegalStateException');
} catch (IllegalStateException $expected) {
$this->assertEquals('', $this->streams[1]->getBytes());
}
}
示例6: opcja
/**
* Ustawia akcję gracza
* @param type $opcja
*/
public function opcja($opcja)
{
switch ($opcja) {
case "a":
$this->gracz->wykonajAtak($this->przeciwnik);
break;
case "b":
Console::write("Podaj poziom Eliksiru");
$this->gracz->utworz_eliksir();
break;
case "c":
$this->gracz->wypij();
break;
case "d":
$this->gracz->wykonajObrone();
break;
default:
// exit();
break;
}
}
示例7: czywypity
/**
* wysyła komunikat ze obiekt elikis juz został uzyty
* @return boolean
*/
public function czywypity()
{
if ($this->czyWypiy == true) {
\Console::write("Zosta.....");
return true;
}
}
示例8: config
function config()
{
Console::write("Reading configuration metadata ... ");
Console::status('dbx ');
sleep(1);
Console::status('dbx.db ');
sleep(1);
Console::status('dbx.db.mysql ');
sleep(1);
Console::writeLn('done ');
Console::writeLn("Parsing configuration file ... done");
Console::writeLn("Preparing options ... done");
}
示例9: printClass
/**
* Handles classes
*
* @param lang.XPClass class
*/
protected static function printClass(XPClass $class)
{
Console::write(implode(' ', Modifiers::namesOf($class->getModifiers())));
Console::write(' class ', self::displayNameOf($class));
if ($parent = $class->getParentClass()) {
Console::write(' extends ', self::displayNameOf($parent));
}
if ($interfaces = $class->getDeclaredInterfaces()) {
Console::write(' implements ');
$s = sizeof($interfaces) - 1;
foreach ($interfaces as $i => $iface) {
Console::write(self::displayNameOf($iface));
$i < $s && Console::write(', ');
}
}
// Constants
Console::writeLine(' {');
$i = 0;
foreach ($class->getConstants() as $name => $value) {
Console::writeLine(' const ', $name, ' = ', xp::stringOf($value));
$i++;
}
// Fields
$i && Console::writeLine();
$i = 0;
foreach ($class->getFields() as $field) {
Console::writeLine(' ', $field);
$i++;
}
// Constructor
$i && Console::writeLine();
$i = 0;
if ($class->hasConstructor()) {
Console::writeLine(' ', $class->getConstructor());
$i++;
}
// Methods
$i && Console::writeLine();
self::printMethods($class->getMethods());
Console::writeLine('}');
}
示例10: parseCreateTable
$old = null;
$arr = $DB->query('show create table `' . $new['name'] . '`');
if (isset($arr[0]['Create Table'])) {
$old = parseCreateTable($arr[0]['Create Table']);
}
if ($old) {
// existent table
$arr = compareTables($old, $new);
if (count($arr)) {
Console::left($new['name'], 30);
foreach ($arr as $key => $q) {
$DB->execute($q);
if (in_array($DB->getError(), $codes)) {
Console::write($key . ' ');
} else {
Console::write($key . ' ');
$error[] = $q;
}
}
Console::writeln();
} else {
}
} else {
Console::left($new['name'], 30);
// new table
$DB->execute($query);
if (in_array($DB->getError(), $codes)) {
Console::writeln('added');
} else {
Console::writeln('FAILED!');
//$error[] = $query;
示例11: extensions
function extensions()
{
$cb = 0;
Console::writeLn(__astr("\\b{Loaded extensions:}"));
$ext = get_loaded_extensions();
sort($ext);
foreach ($ext as $val) {
Console::write(' %-18s', $val);
$cb++;
if ($cb > 3 && $val != end($ext)) {
Console::writeLn();
$cb = 0;
}
}
Console::writeLn();
Console::writeLn();
}
示例12: foreach
Console::write('| ');
foreach ($stats['size'] as $i => $value) {
if ($i == 'a') {
break;
}
Console::left(count(${$i}), 4);
Console::left(File::getFilesize($stats['size'][$i], 'b,K,M,G'), 5);
Console::left($stats['lines'][$i] . 'L', 8);
Console::write('| ');
}
Console::left(count($m) + count($c) + count($v), 4);
Console::left(File::getFilesize($stats['size']['a'], 'b,K,M,G'), 5);
Console::left($stats['lines']['a'] . 'L', 8);
Console::writeln('|');
Console::write('\\');
Console::write(str_repeat('=', 98));
Console::writeln('/');
Console::writeln();
if ($argv[1]) {
$sign = '$';
$time = $price = 0;
$arr = explode('/', $argv[1]);
if (count($arr) == 2) {
$price = $stats['lines']['a'] / $arr[1];
$sign = $arr[0] ? $arr[0] : $sign;
} else {
$price = $stats['lines']['a'] * $arr[1];
}
$time = round($stats['lines']['a'] / 1500);
Console::writeln('Price: ' . Price::show($price) . $sign . ', Time: ' . $time . ' days.');
Console::writeln();
示例13: start
public function start()
{
$this->requests_count = 0;
Console::writeTitle('Welcome to Brutor!');
for ($i = 0; $this->opt['times'] === 'forever' ? true : $i < $this->opt['times']; $i++) {
$wait_per_ip = false;
Console::writeLine("\nProcessing new request (" . ++$this->requests_count . ")", ConsoleColor::purple);
try {
$this->enableTor();
Console::write("New IP is: ");
$this->ip = $this->getIP();
Console::writeLine($this->ip, ConsoleColor::brown);
for ($j = 0; $j < $this->opt['times_per_ip']; $j++) {
Console::write("Making CURL request... ");
$response = $this->curlRequest($this->opt['curl_request']);
Console::writeLine("OK!", ConsoleColor::green);
$continue = @call_user_func($this->opt['curl_continue'], $response) ?: false;
if ($continue == false) {
Console::writeLine("Breaking (globally) caused by 'curl_continue' callback.", ConsoleColor::cyan);
break 2;
}
$continue_per_ip = false;
$continue_per_ip = @call_user_func($this->opt['curl_continue_per_ip'], $response) ?: false;
if ($continue_per_ip == false) {
Console::writeLine("Breaking (per IP) caused by 'curl_continue_per_ip' callback.", ConsoleColor::cyan);
break 1;
}
$wait_per_ip = true;
sleep($this->opt['sleep_per_ip']);
}
$this->disableTor();
if ($wait_per_ip) {
sleep($this->opt['sleep']);
}
} catch (Exception $e) {
Console::writeLine("\n" . $e->getMessage(), ConsoleColor::red);
$this->disableTor();
}
}
}
示例14: start
/**
* Entry point
*
* @param text.doclet.RootDoc root
* @return var
*/
public function start(RootDoc $root)
{
$this->processor = new MarkupBuilder();
// Option: API (will be used in title, default: none)
$this->api = $this->option('api');
// Option: Gen (will be used in footer)
$this->gen = $this->option('gen');
// Option: CSS to embed (filename, default: none)
if ($css = $this->option('css')) {
$this->css = FileUtil::getContents(new File($css));
}
// Option: Output folder (default: Current directory, created if non-existant)
$target = new Folder($this->option('output', '.'));
$target->exists() || $target->create();
// Compute hierarchy
Console::write('[');
$this->hierarchy = array();
$seen = array();
while ($this->classes->hasNext()) {
$class = $this->classes->next();
if (isset($seen[$class->qualifiedName()])) {
continue;
}
$seen[$class->qualifiedName()] = TRUE;
$key = $class->containingPackage()->name();
if (!isset($this->hierarchy[$key])) {
$sub = new Folder($target, strtr($key, '.', DIRECTORY_SEPARATOR));
$sub->exists() || $sub->create();
$this->hierarchy[$key] = array('target' => $sub, 'doc' => $class->containingPackage(), 'contents' => array(INTERFACE_CLASS => array(), ORDINARY_CLASS => array(), ENUM_CLASS => array(), EXCEPTION_CLASS => array(), ERROR_CLASS => array()));
}
Console::write('.');
$this->hierarchy[$key]['contents'][$class->classType()][] = $class;
}
// Generate HTML files
Console::write('>');
$this->writeOverview($this->hierarchy, $target)->close();
Console::writeLine($target, ']');
}
示例15: getFiles
public function getFiles()
{
Console::write("Reading file database: ");
$fn = 'zip://' . $this->packagename . '#' . $this->filedb;
Console::write("%s ... ", $fn);
$fh = fopen($fn, 'r');
$files = array();
while (!feof($fh)) {
$fl = fgets($fh);
while (strpos($fl, " ") !== false) {
$fl = str_replace(" ", " ", $fl);
}
$fd = explode(" ", str_replace("\n", "", $fl));
$files[] = array('filename' => $fd[1], 'md5' => $fd[0]);
}
Console::writeLn("Done");
return $files;
}