本文整理匯總了PHP中printf函數的典型用法代碼示例。如果您正苦於以下問題:PHP printf函數的具體用法?PHP printf怎麽用?PHP printf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了printf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: genesis_404
/**
* This function outputs a 404 "Not Found" error message
*
* @since 1.6
*/
function genesis_404()
{
echo genesis_html5() ? '<article class="entry">' : '<div class="post hentry">';
printf('<h1 class="entry-title">%s</h1>', apply_filters('genesis_404_entry_title', __('Not found, error 404', 'genesis')));
echo '<div class="entry-content">';
if (genesis_html5()) {
echo apply_filters('genesis_404_entry_content', '<p>' . sprintf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it by using the search form below.', 'genesis'), trailingslashit(home_url())) . '</p>');
get_search_form();
} else {
?>
<p><?php
printf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it with the information below.', 'genesis'), trailingslashit(home_url()));
?>
</p>
<?php
}
if (!genesis_html5()) {
genesis_sitemap('h4');
} elseif (genesis_a11y('404-page')) {
echo '<h2>' . __('Sitemap', 'genesis') . '</h2>';
genesis_sitemap('h3');
}
echo '</div>';
echo genesis_html5() ? '</article>' : '</div>';
}
示例2: commentlist
function commentlist($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
?>
<li id="li-comment-<?php
comment_ID();
?>
">
<div id="comment-<?php
comment_ID();
?>
" <?php
comment_class('comment_item clear');
?>
>
<div class="comment_meta">Posted on <?php
printf(__('%1$s'), get_comment_date());
?>
by <?php
printf(__('<cite class="fn">%s</cite>'), get_comment_author_link());
?>
</div>
<div class="comment_text"><?php
comment_text();
?>
</div>
</div>
<?php
}
示例3: missing_plugins_warning
/**
* Missing plugins warning.
*/
public function missing_plugins_warning()
{
if ($this->missing) {
$missing = '';
$missing_slugs = array();
$counter = 0;
foreach ($this->missing as $title => $data) {
$url = $data['url'];
$missing_slugs[] = 'wpml-missing-' . sanitize_title_with_dashes($data['slug']);
$counter++;
if (sizeof($this->missing) == $counter) {
$sep = '';
} elseif (sizeof($this->missing) - 1 == $counter) {
$sep = ' ' . __('and', 'wpml-translation-management') . ' ';
} else {
$sep = ', ';
}
$missing .= '<a href="' . $url . '">' . $title . '</a>' . $sep;
}
$missing_slugs_classes = implode(' ', $missing_slugs);
?>
<div class="message error wpml-admin-notice wpml-gfml-inactive <?php
echo $missing_slugs_classes;
?>
"><p><?php
printf(__('Gravity Forms Multilingual is enabled but not effective. It requires %s in order to work.', 'wpml-translation-management'), $missing);
?>
</p></div>
<?php
}
}
示例4: _pb_minimum_wp
/**
* Echo message about minimum WordPress Version
*/
function _pb_minimum_wp()
{
global $pb_minimum_wp;
echo '<div id="message" class="error fade"><p>';
printf(__('Pressbooks will not work with your version of WordPress. Pressbooks requires a dedicated install of WordPress Multi-Site, version %s or greater. Please upgrade WordPress if you would like to use Pressbooks.', 'pressbooks'), $pb_minimum_wp);
echo '</p></div>';
}
示例5: processPacket
function processPacket($packetData)
{
$packet = new dhcpPacket();
$packet->parse($packetData);
$processor = new dhcpRequestProcessor($this, $this->packetProcessor, $this->storage, $packet);
if ($responsePacket = $processor->getResponse()) {
$responseData = $responsePacket->build();
$this->verbosity && (print "Sending response" . "\n");
$ciaddr = $packet->getClientAddress();
if ($ciaddr == '0.0.0.0') {
$this->verbosity && (print "Switching to broadcast address...\n");
$ciaddr = '255.255.255.255';
}
$this->verbosity && (print "Attempting to send response packet to " . $ciaddr . "\n");
$numBytesSent = socket_sendto($this->socket, $responseData, strlen($responseData), 0, $ciaddr, 68);
if ($numBytesSent === FALSE) {
$this->verbosity && (print "send failed for specific address, broadcast.\n");
$numBytesSent = socket_sendto($this->socket, $responseData, strlen($responseData), 0, "255.255.255.255", 68);
$numBytesSent === FALSE && $this->verbosity && printf('socket send error: %s\\n', socket_strerror(socket_last_error($this->socket)));
}
$numBytesSent && $this->verbosity && (print "Response packet sent.\n");
} else {
$this->verbosity && (print "Packet ignored\n");
}
}
示例6: AddTextAdsExample
function AddTextAdsExample(AdWordsUser $user, $adGroupId)
{
// Get the service, which loads the required classes.
$adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
$numAds = 5;
$operations = array();
for ($i = 0; $i < $numAds; $i++) {
// Create text ad.
$textAd = new TextAd();
$textAd->headline = 'Cruise #' . uniqid();
$textAd->description1 = 'Visit the Red Planet in style.';
$textAd->description2 = 'Low-gravity fun for everyone!';
$textAd->displayUrl = 'www.example.com';
$textAd->finalUrls = array('http://www.example.com');
// Create ad group ad.
$adGroupAd = new AdGroupAd();
$adGroupAd->adGroupId = $adGroupId;
$adGroupAd->ad = $textAd;
// Set additional settings (optional).
$adGroupAd->status = 'PAUSED';
// Create operation.
$operation = new AdGroupAdOperation();
$operation->operand = $adGroupAd;
$operation->operator = 'ADD';
$operations[] = $operation;
}
// Make the mutate request.
$result = $adGroupAdService->mutate($operations);
// Display results.
foreach ($result->value as $adGroupAd) {
printf("Text ad with headline '%s' and ID '%s' was added.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
}
}
示例7: tearDownAfterClass
public static function tearDownAfterClass()
{
if (!self::$timing) {
echo "\n";
return;
}
$class = get_called_class();
echo "Timing results : {$class}\n";
$s = sprintf("%40s %6s %9s %9s %4s\n", 'name', 'count', 'total', 'avg', '% best');
echo str_repeat('=', strlen($s)) . "\n";
echo $s;
echo str_repeat('-', strlen($s)) . "\n";
array_walk(self::$timing, function (&$value, $key) {
$value['avg'] = round($value['total'] / $value['count'] * 1000000, 3);
});
usort(self::$timing, function ($a, $b) {
$at = $a['avg'];
$bt = $b['avg'];
return $at === $bt ? 0 : ($at < $bt ? -1 : 1);
});
$best = self::$timing[0]['avg'];
foreach (self::$timing as $timing) {
printf("%40s %6d %7.3fms %7.3fus %4.1f%%\n", $timing['name'], $timing['count'], round($timing['total'] * 1000, 3), $timing['avg'], round($timing['avg'] / $best * 100, 3));
}
echo str_repeat('-', strlen($s)) . "\n\n";
printf("\nTiming compensated for avg overhead for: timeIt of %.3fus and startTimer/endTimer of %.3fus per invocation\n\n", self::$timeItOverhead * 1000000, self::$startEndOverhead * 1000000);
parent::tearDownAfterClass();
}
示例8: rows
/**
* Displays the server list
*/
function rows($result)
{
global $fmdb;
$num_rows = $fmdb->num_rows;
$results = $fmdb->last_result;
if (currentUserCan('build_server_configs', $_SESSION['module'])) {
$bulk_actions_list = array(__('Upgrade'), __('Build Config'));
$title_array[] = array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'server_list[]\')" />', 'class' => 'header-tiny');
} else {
$bulk_actions_list = null;
}
if (!$result) {
printf('<p id="table_edits" class="noresult" name="servers">%s</p>', __('There are no firewall servers.'));
} else {
echo @buildBulkActionMenu($bulk_actions_list, 'server_id_list');
$table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'servers');
$title_array[] = array('class' => 'header-tiny');
$title_array = array_merge($title_array, array(__('Hostname'), __('Method'), __('Firewall Type'), __('Version'), __('Config File')));
$title_array[] = array('title' => __('Actions'), 'class' => 'header-actions');
echo displayTableHeader($table_info, $title_array);
for ($x = 0; $x < $num_rows; $x++) {
$this->displayRow($results[$x]);
}
echo "</tbody>\n</table>\n";
}
}
示例9: directoryAction
/**
* Create Icinga Web 2's configuration directory
*
* USAGE:
*
* icingacli setup config directory [options]
*
* OPTIONS:
*
* --config=<directory> Path to Icinga Web 2's configuration files [/etc/icingaweb2]
*
* --mode=<mode> The access mode to use [2770]
*
* --group=<group> Owner group for the configuration directory [icingaweb2]
*
* EXAMPLES:
*
* icingacli setup config directory
*
* icingacli setup config directory --mode=2775 --config=/opt/icingaweb2/etc
*/
public function directoryAction()
{
$configDir = trim($this->params->get('config', $this->app->getConfigDir()));
if (strlen($configDir) === 0) {
$this->fail($this->translate('The argument --config expects a path to Icinga Web 2\'s configuration files'));
}
$group = trim($this->params->get('group', 'icingaweb2'));
if (strlen($group) === 0) {
$this->fail($this->translate('The argument --group expects a owner group for the configuration directory'));
}
$mode = trim($this->params->get('mode', '2770'));
if (strlen($mode) === 0) {
$this->fail($this->translate('The argument --mode expects an access mode for the configuration directory'));
}
if (!file_exists($configDir) && !@mkdir($configDir)) {
$e = error_get_last();
$this->fail(sprintf($this->translate('Can\'t create configuration directory %s: %s'), $configDir, $e['message']));
}
if (!@chmod($configDir, octdec($mode))) {
$e = error_get_last();
$this->fail(sprintf($this->translate('Can\'t change the mode of the configuration directory to %s: %s'), $mode, $e['message']));
}
if (!@chgrp($configDir, $group)) {
$e = error_get_last();
$this->fail(sprintf($this->translate('Can\'t change the group of %s to %s: %s'), $configDir, $group, $e['message']));
}
printf($this->translate('Successfully created configuration directory %s') . PHP_EOL, $configDir);
}
示例10: endElement
function endElement($parser, $tagName)
{
if ($tagName == "ITEM") {
if ($this->status) {
print "[{$this->status}] ";
}
printf("<a href='%s' target='_content'>%s</a>", trim($this->link), htmlspecialchars(trim($this->title)));
#printf("<p>%s</p>",
# htmlspecialchars(trim($this->description)));
if ($this->date) {
$date = trim($this->date);
$date[10] = " ";
# 2003-07-11T12:08:33+09:00
# http://www.w3.org/TR/NOTE-datetime
$zone = str_replace(":", "", substr($date, 19));
$time = strtotime(substr($date, 0, 19) . $zone);
$date = date("@ m-d [h:i a]", $time);
printf(" %s<br />\n", htmlspecialchars(trim($date)));
} else {
printf("<br />\n");
}
$this->title = "";
$this->description = "";
$this->link = "";
$this->date = "";
$this->status = "";
$this->insideitem = false;
}
}
示例11: display
public function display()
{
$this->echoOptionHeader();
?>
<select name="<?php
echo $this->getID();
?>
"><?php
foreach ($this->settings['options'] as $value => $label) {
// this is if we have option groupings
if (is_array($label)) {
?>
<optgroup label="<?php
echo $value;
?>
"><?php
foreach ($label as $subValue => $subLabel) {
printf("<option value=\"%s\" %s>%s</option>", $subValue, selected($this->getValue(), $subValue, false), $subLabel);
}
?>
</optgroup><?php
// this is for normal list of options
} else {
printf("<option value=\"%s\" %s>%s</option>", $value, selected($this->getValue(), $value, false), $label);
}
}
?>
</select><?php
$this->echoOptionFooter();
}
示例12: printBtn
/**
* @brief Button to output
**/
function printBtn()
{
if ($this->nextUrl) {
$url = $this->nextUrl;
printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
}
if ($this->prevUrl) {
$url = $this->prevUrl;
printf('<a href="%s">%s</a><br>%s', $url->url, $url->text, "\n");
}
// Select Language
if (!parent::isLangChange()) {
$url = getUrl('', 'lcm', '1', 'sel_lang', Context::getLangType(), 'return_uri', Context::get('current_url'));
printf('<a href="%s">%s</a><br>%s', $url, 'Language : ' . Context::getLang('select_lang'), "\n");
} else {
printf('<a href="%s">%s</a><br>%s', Context::get('return_uri'), Context::getLang('lang_return'), "\n");
}
if ($this->upperUrl) {
$url = $this->upperUrl;
printf('<btn href="%s" name="%s">%s', $url->url, $url->text, "\n");
}
if ($this->homeUrl) {
$url = $this->homeUrl;
printf('<a btn="%s" href="%s">%s</a><br>%s', $url->text, $url->url, $url->text, "\n");
}
}
示例13: DownloadCriteriaReportExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
* @param string $filePath the path of the file to download the report to
*/
function DownloadCriteriaReportExample(AdWordsUser $user, $filePath)
{
// Load the service, so that the required classes are available.
$user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost');
// Optional: use predicate to filter out paused criteria.
$selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED'));
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->selector = $selector;
$reportDefinition->reportName = 'Criteria performance report #' . uniqid();
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSV';
// Exclude criteria that haven't recieved any impressions over the date range.
$reportDefinition->includeZeroImpressions = false;
// Set additional options.
$options = array('version' => ADWORDS_VERSION);
// Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
// suppress headers or summary rows.
// $options['skipReportHeader'] = true;
// $options['skipColumnHeader'] = true;
// $options['skipReportSummary'] = true;
// Optional: Set includeZeroImpressions to include zero impression rows in
// the report output.
// $options['includeZeroImpressions'] = true;
// Download report.
ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath);
}
示例14: array
/**
* ScaffoldActionForm を生成する
*
* @access public
* @param $model string テーブル名
* @param $modelDefine array モデル定義
* @param $formDef array フォーム定義
*/
function &generate($model, $modelDefine, $formDef)
{
$table_id = $this->_getTableId($model);
$project_id = $this->ctl->getAppId();
$dir = $this->ctl->getDirectory('action_form');
if ($dir == null) {
$dir = $this->ctl->getDirectory('app') . "/action_form/";
}
$file = "{$project_id}_{$table_id}_ActionForm.php";
// Macro
$macro = array();
$macro['model'] = $model;
$macro['modelName'] = $table_id;
$macro['modelUName'] = strtoupper($table_id);
$macro['project_id'] = $project_id;
$macro['column_name_file'] = $this->_getColumnNamePath($table_id);
$macro['form_define'] = $this->_getActionFormDefine($formDef);
$user_macro = $this->_getUserMacro();
$macro = array_merge($macro, $user_macro);
$skelton = "skel.scaffold-actionform.php";
// ファイル生成
$path = "{$dir}{$file}";
Ethna_Util::mkdir(dirname($path), 0755);
if (file_exists($path)) {
printf("file [%s] already exists -> skip\n", $path);
} else {
if ($this->_generateFile($skelton, $path, $macro) == false) {
printf("[warning] file creation failed [%s]\n", $path);
} else {
printf("action script(s) successfully created [%s]\n", $path);
}
}
$true = true;
return $true;
}
示例15: pla_rdelete
function pla_rdelete($server, $dn)
{
# We delete all children, not only the visible children in the tree
$children = $server->getContainerContents($dn, null, 0, '(objectClass=*)', LDAP_DEREF_NEVER);
if (!is_array($children) || count($children) == 0) {
printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
if ($server->delete($dn)) {
printf(' <span style="color:green">%s</span></span><br />', _('Success'));
return true;
} else {
system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
}
} else {
foreach ($children as $child_dn) {
pla_rdelete($server, $child_dn);
}
printf('<span style="white-space: nowrap;">%s %s...', _('Deleting'), $dn);
if ($server->delete($dn)) {
printf(' <span style="color:green">%s</span></span><br />', _('Success'));
return true;
} else {
system_message(array('title' => _('Could not delete the entry.') . sprintf(' (%s)', pretty_print_dn($dn)), 'body' => ldap_error_msg($server->getErrorMessage(null), $server->getErrorNum(null)), 'type' => 'error'));
}
}
}