本文整理汇总了PHP中fprintf函数的典型用法代码示例。如果您正苦于以下问题:PHP fprintf函数的具体用法?PHP fprintf怎么用?PHP fprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: usage
function usage()
{
fprintf(STDERR, "Usage: php midigrep.php -f <midi_file> [-r] {-c <channels> | -C <channels>}\n");
fprintf(STDERR, "ex) php midigrep.php -f in.mid -c 1\n");
fprintf(STDERR, "ex) php midigrep.php -f in.mid -c 1,2\n");
fprintf(STDERR, "ex) php midigrep.php -f in.mid -C 15,16\n");
}
开发者ID:yoya,项目名称:io_midi,代码行数:7,代码来源:midigrep.php
示例2: registerUser
function registerUser($userName, $userMail, $userPasswd, $salt)
{
$fileMail = fopen("database/email", "a+");
if ($fileMail) {
mkdir("database/users/{$userName}", 0755);
mkdir("database/users/{$userName}/tasks", 0755);
$fileName = fopen("database/users/{$userName}/{$userName}.usr", "a+");
if ($fileName) {
$filePasswd = fopen("database/passwd", "a+");
if ($filePasswd) {
/* creating user file in database */
/* registering e-mail adress in database */
fprintf($fileMail, "{$userMail}\n");
fprintf($fileName, "{$userName}:{$userMail}\n");
/* registering user's password in database */
$PasswdCrypt = sha1(sha1("{$userPasswd}") . $salt);
fprintf($filePasswd, "{$userName}:{$PasswdCrypt}\n");
fclose($fileName);
} else {
rmdir("database/users/{$userName}");
rmdir("database/users/{$userName}/tasks");
}
fclose($fileMail);
} else {
rmdir("database/users/{$userName}");
rmdir("database/users/{$userName}/tasks");
}
fclose($filePasswd);
}
}
开发者ID:Gawil,项目名称:tasker,代码行数:30,代码来源:functionsUser.php
示例3: exportCSV
/**
* @param mixed $data A Traversable of CModel or a CModel where data will be fetch from
* @param array $attributes Attribute names of CModel to be exported.
* @param bool $endApplication Application will be ended if true. false to keep going and export more data. Defautls to TRUE.
* @param integer $endLineCount Number of newlines to append below this data. Defaults to 0.
*/
public function exportCSV($data, $attributes = array(), $endApplication = true, $endLineCount = 0)
{
if ($this->isExportRequest()) {
$this->sendHeaders();
$fileHandle = fopen('php://output', 'w');
if ($data instanceof CActiveDataProvider) {
$this->csvRowHeaders($fileHandle, $attributes, $data->model);
$this->csvRowModels($fileHandle, new CDataProviderIterator($data, 150), $attributes);
} else {
if (is_array($data) && current($data) instanceof CModel) {
$this->csvRowHeaders($fileHandle, $attributes, current($data));
$this->csvRowModels($fileHandle, $data, $attributes);
} else {
if (is_array($data) && is_string(current($data))) {
fputcsv($fileHandle, $data, $this->csvDelimiter, $this->csvEnclosure);
} else {
if ($data instanceof CModel) {
$this->csvModel($fileHandle, $data, $attributes);
}
}
}
}
fprintf($fileHandle, str_repeat("\n", $endLineCount));
fclose($fileHandle);
if ($endApplication) {
Yii::app()->end(0, false);
exit(0);
}
}
}
开发者ID:seventrust,项目名称:jquiroz,代码行数:36,代码来源:ExportableGridBehavior.php
示例4: do_app
function do_app($app)
{
// enumerate the host_app_versions for this app,
// joined to the host
$db = BoincDb::get();
$query = "select et_avg, host.on_frac, host.active_frac, host.gpu_active_frac, app_version.plan_class " . " from DBNAME.host_app_version, DBNAME.host, DBNAME.app_version " . " where host_app_version.app_version_id = app_version.id " . " and app_version.appid = {$app->id} " . " and et_n > 0 and et_avg > 0 " . " and host.id = host_app_version.host_id";
$result = $db->do_query($query);
$a = array();
while ($x = _mysql_fetch_object($result)) {
if (is_gpu($x->plan_class)) {
$av = $x->on_frac;
if ($x->gpu_active_frac) {
$av *= $x->gpu_active_frac;
} else {
$av *= $x->active_frac;
}
} else {
$av = $x->on_frac * $x->active_frac;
}
$a[] = 1 / $x->et_avg * $av;
}
_mysql_free_result($result);
sort($a);
$n = count($a);
$f = fopen("../../size_census_" . $app->name, "w");
for ($i = 1; $i < $app->n_size_classes; $i++) {
$k = (int) ($i * $n / $app->n_size_classes);
fprintf($f, "%e\n", $a[$k]);
}
fclose($f);
}
开发者ID:suno,项目名称:boinc,代码行数:31,代码来源:size_census.php
示例5: execute
/**
* Execute the command
*/
function execute()
{
$stderr = fopen('php://stdout', 'w');
$locales = AppLocale::getAllLocales();
$dbConn = DBConnection::getConn();
foreach ($locales as $locale => $localeName) {
fprintf($stderr, "Checking {$localeName}...\n");
$oldTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->oldTag);
$newTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->newTag);
if ($oldTemplatesText === false || $newTemplatesText === false) {
fprintf($stderr, "Skipping {$localeName}; could not fetch.\n");
continue;
}
$oldEmails = $this->parseEmails($oldTemplatesText);
$newEmails = $this->parseEmails($newTemplatesText);
foreach ($oldEmails['email_text'] as $oi => $junk) {
$key = $junk['attributes']['key'];
$ni = null;
foreach ($newEmails['email_text'] as $ni => $junk) {
if ($key == $junk['attributes']['key']) {
break;
}
}
if ($oldEmails['subject'][$oi]['value'] != $newEmails['subject'][$ni]['value']) {
echo "UPDATE email_templates_default_data SET subject='" . $dbConn->escape($newEmails['subject'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND subject='" . $dbConn->escape($oldEmails['subject'][$oi]['value']) . "';\n";
}
if ($oldEmails['body'][$oi]['value'] != $newEmails['body'][$ni]['value']) {
echo "UPDATE email_templates_default_data SET body='" . $dbConn->escape($newEmails['body'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND body='" . $dbConn->escape($oldEmails['body'][$oi]['value']) . "';\n";
}
}
}
fclose($stderr);
}
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:36,代码来源:genEmailUpdates.php
示例6: eputsf
function eputsf()
{
$args = func_get_args();
$fmt = array_shift($args);
fprintf(STDERR, $fmt, $args);
fprintf(STDERR, "%s", PHP_EOL);
}
开发者ID:narupo,项目名称:bottle,代码行数:7,代码来源:cl.php
示例7: ctx_log_msg
function ctx_log_msg($func, $text, $type)
{
global $_context_log;
if ($_context_log) {
fprintf($_context_log, "%f %s %d %d %s %s %s\n", microtime(true), php_uname('n'), posix_getpid(), posix_getpid(), $type, $func, $text);
}
}
开发者ID:nsuan,项目名称:shimmie2,代码行数:7,代码来源:context.php
示例8: usage
function usage()
{
global $argv;
fprintf(STDERR, "Usage: %s -u <URL> -n <requests> -c <concurrency> -e (use libevent)\n", $argv[0]);
fprintf(STDERR, "\nDefaults: -u http://localhost/ -n 1000 -c 10\n\n");
exit(-1);
}
开发者ID:garybulin,项目名称:php7,代码行数:7,代码来源:bench_select_vs_event.php
示例9: main_loop
/**
* Simple tail program using the inotify extension
* Usage: ./tail.php file
*/
function main_loop($file, $file_fd)
{
$inotify = inotify_init();
if ($inotify === false) {
fprintf(STDERR, "Failed to obtain an inotify instance\n");
return 1;
}
$watch = inotify_add_watch($inotify, $file, IN_MODIFY);
if ($watch === false) {
fprintf(STDERR, "Failed to watch file '%s'", $file);
return 1;
}
while (($events = inotify_read($inotify)) !== false) {
echo "Event received !\n";
foreach ($events as $event) {
if (!($event['mask'] & IN_MODIFY)) {
continue;
}
echo stream_get_contents($file_fd);
break;
}
}
// May not happen
inotify_rm_watch($inotify, $watch);
fclose($inotify);
fclose($file_fd);
return 0;
}
开发者ID:diesse,项目名称:php7-inotify,代码行数:32,代码来源:tail.php
示例10: processList
/**
* processList -
*/
function processList()
{
//$filename = 'titlelisting.txt';
$fp = fopen(self::RPT_FILENAME, 'w');
if ($fp) {
$this->fp = $fp;
}
//select nid, title from node order by title;
//$sql = 'SELECT nid, title FROM node ORDER BY title, nid LIMIT 50';
//$sql = "SELECT nid, title FROM node WHERE TYPE = 'biblio' ORDER BY title, nid LIMIT 500";
//SELECT n.nid, n.title FROM node AS n JOIN biblio AS b ON (b.nid = n.nid) WHERE b.biblio_label LIKE '%Pensoft%' AND n.type = 'biblio' ORDER BY n.title, n.nid LIMIT 10;
$sql = "SELECT nid, title FROM node WHERE TYPE = 'biblio' ORDER BY title, nid";
//$sql = "SELECT n.nid, n.title FROM node AS n JOIN biblio AS b ON (b.nid = n.nid) WHERE b.biblio_label LIKE '%Pensoft%' AND n.type = 'biblio' ORDER BY n.title, n.nid";
$titleList = $this->dbi->fetch($sql);
foreach ($titleList as $titleItem) {
//$msg = '' . $titleItem['nid'] . ' ' . (trim($titleItem['title']) ? $titleItem['title'] : 'NO TITLE') . ' ';
$msg = '' . $titleItem['nid'] . (strlen($titleItem['nid']) == 6 ? '' : ' ') . ' ' . (trim($titleItem['title']) ? $titleItem['title'] : 'NO TITLE') . ' ';
fprintf($this->fp, '%s', $msg);
fprintf($this->fp, '%s', PHP_EOL);
}
if ($this->fp) {
fclose($this->fp);
}
echo date('YmdHis');
}
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:28,代码来源:ListTitles.php
示例11: export
function export($is_user, $dir)
{
$n = 0;
$filename = $is_user ? "{$dir}/user_work" : "{$dir}/team_work";
$f = fopen($filename, "w");
if (!$f) {
die("fopen");
}
$is_user ? fprintf($f, "<users>\n") : fprintf($f, "<teams>\n");
$maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id");
while ($n <= $maxid) {
$m = $n + 1000;
if ($is_user) {
$items = BoincUser::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
} else {
$items = BoincTeam::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
}
foreach ($items as $item) {
export_item($item, $is_user, $f);
}
$n = $m;
}
$is_user ? fprintf($f, "</users>\n") : fprintf($f, "</teams>\n");
fclose($f);
system("gzip -f {$filename}");
}
开发者ID:CalvinZhu,项目名称:boinc,代码行数:26,代码来源:export_credit_by_app.php
示例12: write_row
function write_row($handle, $row)
{
foreach ($row as $key => $value) {
$row[$key] = preg_replace("/\"/", "\"\"", $value);
}
fprintf($handle, "\"%s\"\n", implode("\",\"", $row));
}
开发者ID:henrytao-me,项目名称:testrail-converter,代码行数:7,代码来源:csvformatter.php
示例13: write
public function write($message, $sev = 0)
{
$tag;
if ($sev < $this->debugLevel) {
return;
}
date_default_timezone_set("GMT");
switch ($sev) {
case 0:
$tag = "notice";
break;
case 1:
$tag = "warn";
break;
case 3:
$tag = "error";
break;
case 9:
$tag = "security";
break;
default:
$tag = "notice";
break;
}
$message = sprintf("[%s] [%s] [ppg] [session:%s] [prog:%s] : %s", date('D M d H:i:s Y'), $tag, $this->sessId, $this->caller, $message);
fprintf($this->errorHandle, "%s\n", $message);
}
开发者ID:Altihex,项目名称:PPG-source,代码行数:27,代码来源:logger.php
示例14: prepare
/**
* @inheritdoc
*/
public function prepare()
{
if ($this->utf8Encoding) {
fprintf($this->getStream(), chr(0xef) . chr(0xbb) . chr(0xbf));
}
return $this;
}
开发者ID:lmkhang,项目名称:mcntw,代码行数:10,代码来源:CsvWriter.php
示例15: createcfg
function createcfg($type = null)
{
$term = \Cherry\Cli\Console::getAdapter();
if (!$type) {
fprintf(STDERR, "No such config. Try " . Ansi::setUnderline() . "list-configs" . Ansi::clearUnderline() . "\n");
return 1;
}
$args = func_get_args();
$type = $args[0];
$opts = $this->parseOpts(array_slice($args, 1), array('verbose' => '+verbose', 'dest' => 'to:', 'force' => '+force'));
if ($type) {
$this->data = new TemplateStrings();
$this->data->htmlroot = exec('pwd');
$this->data->environment = 'prodution';
$tpl = (require CHERRY_LIB . '/share/configs/' . $type . '.php');
$meta = parse_ini_file(CHERRY_LIB . '/share/configs/' . $type . '.ini', true);
if (empty($opts['dest'])) {
$out = $meta['config']['dest'];
} else {
$out = $opts['dest'];
}
fprintf(STDOUT, "Writing %s...\n", $out);
if (file_exists($out)) {
if (empty($opts['force']) || $opts['force'] == 0) {
fprintf(STDERR, "Error: File already exists! To replace use +force\n");
return 1;
}
}
file_put_contents($out, trim($tpl) . "\n");
}
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:31,代码来源:application.php
示例16: actionIndex
/**
* Lists all ClientEmployee models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ClientEmployeeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if (isset($_GET['download'])) {
$datetime_start = str_replace('\'', '', $_GET['datetime_start']);
$datetime_end = str_replace('\'', '', $_GET['datetime_end']);
$filename = Yii::$app->getRuntimePath() . "/员工会员推广排行榜-" . $datetime_start . '到' . $datetime_end . '.csv';
$fh = fopen($filename, 'w');
fprintf($fh, "排名,会员推广数量,员工姓名,电话,营业厅" . PHP_EOL);
$i = 1;
\Yii::warning('yjhu:' . $datetime_start);
$rows = \app\models\MUser::getMemberPromotionTopList(0, 5000, $datetime_start . ' 00:00:00', $datetime_end . ' 23:59:59');
foreach ($rows as $row) {
$staff = \app\models\MStaff::findOne(['scene_id' => $row['scene_pid']]);
fprintf($fh, $i++ . ',');
fprintf($fh, $row['members'] . ',');
fprintf($fh, $staff->name . ',');
fprintf($fh, $staff->mobile . ',');
fprintf($fh, (empty($staff->office) ? '' : $staff->office->title) . PHP_EOL);
}
fclose($fh);
Yii::$app->response->sendFile($filename);
return;
}
return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
}
开发者ID:noikiy,项目名称:wowewe,代码行数:31,代码来源:ClientEmployeeController.php
示例17: failure
function failure()
{
// this is why error_get_last() should return a stdClass object
$error = error_get_last();
fprintf(STDERR, "FAILURE: %s\n", $error["message"]);
exit(-1);
}
开发者ID:nickl-,项目名称:pecl-http,代码行数:7,代码来源:gen_curlinfo.php
示例18: execute
public function execute()
{
curl_setopt_array($this->hcurl, [CURLOPT_VERBOSE => 1, CURLOPT_HEADER => 1, CURLOPT_AUTOREFERER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_MAXREDIRS => 10]);
switch ($this->method) {
case 'head':
curl_setopt_array($this->hcurl, [CURLOPT_NOBODY => 1]);
break;
case 'get':
curl_setopt_array($this->hcurl, [CURLOPT_RETURNTRANSFER => 1]);
break;
case 'post':
curl_setopt_array($this->hcurl, [CURLOPT_RETURNTRANSFER => 1]);
break;
case 'put':
break;
default:
fprintf(STDERR, "Bad request method: %s\n", $this->method);
}
$response = curl_exec($this->hcurl);
// Then, after your curl_exec call:
$header_size = curl_getinfo(${$this}->hcurl, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$this->resheaders = explode("\r\n", $header);
$this->resbody = substr($response, $header_size);
$this->resmeta = curl_getinfo($this->hcurl);
$this->rescode = curl_getmeta($this->hcurl, CURLINFO_HTTP_CODE);
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:27,代码来源:curlclient.php
示例19: dump
/**
* Dump an array of Paths
*
* @param mixed $paths a single Path object or an array of Path objects
* @param stream $handle
*/
public function dump($paths, $handle)
{
if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
throw new Exception("Not a stream resource");
}
if (!is_array($paths)) {
$paths = array($paths);
}
$nodes = array();
$rels = array();
foreach ($paths as $path) {
if (!$path instanceof Path) {
throw new Exception("Not a Path");
}
$pathNodes = $path->getNodes();
foreach ($pathNodes as $node) {
$nodes[$node->getId()] = $node;
}
$pathRels = $path->getRelationships();
foreach ($pathRels as $rel) {
$rels[$rel->getId()] = $rel;
}
}
foreach ($nodes as $id => $node) {
$properties = $node->getProperties();
$format = $properties ? "(%s)\t%s\n" : "(%s)\n";
fprintf($handle, $format, $id, json_encode($properties));
}
foreach ($rels as $id => $rel) {
$properties = $rel->getProperties();
$format = "(%s)-[%s:%s]->(%s)";
$format .= $properties ? "\t%s\n" : "\n";
fprintf($handle, $format, $rel->getStartNode()->getId(), $id, $rel->getType(), $rel->getEndNode()->getId(), json_encode($properties));
}
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:41,代码来源:Exporter.php
示例20: parseOpts
protected function parseOpts(array $args, array $rules)
{
$out = array();
for ($optidx = 0; $optidx < count($args); $optidx++) {
$opt = $args[$optidx];
$matched = false;
foreach ($rules as $name => $rule) {
if ($rule[strlen($rule) - 1] == ':') {
$rulestr = substr($rule, 0, strlen($rule) - 1);
if ($opt == $rulestr) {
$out[$name] = $args[$optidx + 1];
$optidx++;
$matched = true;
}
} elseif ($rule[0] == '+') {
if ($opt == $rule) {
$out[$name] = true;
$matched = true;
}
}
}
if (!$matched) {
fprintf(STDERR, "Unknown option: %s\n", $opt);
}
}
return $out;
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:27,代码来源:commandbundle.php
注:本文中的fprintf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论