• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP format函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

 /**
  * Returns an array of audience objects
  *
  * @param int $dataProviderId
  * @param |DateTime $from
  * @param |DateTime $to
  * @param array $groupBy
  *
  * @throws Exception\ApiException if the API call fails
  *
  * @return DataProviderAudience[]
  */
 public function get($dataProviderId, $from, $to, $groupBy)
 {
     // Endpoint URI
     $uri = 'v1/dataproviders/' . $dataProviderId . '/audience';
     $options = ['query' => ['from' => $from->format('c'), 'to' => $to->format('c'), 'groupBy' => $groupBy]];
     $dataProviderAudiences = [];
     try {
         $data = null;
         // try to get from cache
         if ($this->cache) {
             $data = $this->cache->get($this->cachePrefix, $uri, $options);
         }
         // load from API
         if (!$data) {
             $data = $this->httpClient->get($uri, $options)->getBody()->getContents();
             if ($this->cache and $data) {
                 $this->cache->put($this->cachePrefix, $uri, $options, $data);
             }
         }
         $classArray = json_decode($data);
         foreach ($classArray as $class) {
             $dataProviderAudiences[] = DataProviderAudienceHydrator::fromStdClass($class);
         }
     } catch (ClientException $e) {
         $response = $e->getResponse();
         $responseBody = $response->getBody()->getContents();
         $responseCode = $response->getStatusCode();
         throw new Exception\ApiException($responseBody, $responseCode);
     }
     return $dataProviderAudiences;
 }
开发者ID:toxonics,项目名称:adform-client,代码行数:43,代码来源:DataProviderAudienceProvider.php


示例2: interpolate

/**
 * Modify a string by replacing named tokens with matching assoc. array values.
 * @param {String} string The string to modify.
 * @param {Array} assoc The template assoc. array.
 * @returns {String} The modified string.
 */
function interpolate($string, $assoc)
{
    foreach ($assoc as $key => $value) {
        $string = preg_replace("/#\\{" . $key . "\\}/", trim((string) $value), $string);
    }
    return format($string);
}
开发者ID:chukcha-wtf,项目名称:art,代码行数:13,代码来源:parse.php


示例3: get

 /**
  * Returns an array of data usage objects
  *
  * @param int $dataProviderId
  * @param |DateTime $from
  * @param |DateTime $to
  * @param array $groupBy
  * @param int $limit
  * @param int $offset
  *
  * @throws Exception\ApiException if the API call fails
  *
  * @return array
  */
 public function get($dataProviderId, $from, $to, $groupBy, $limit = 1000, $offset = 0)
 {
     // Endpoint URI
     $uri = 'v1/reports/datausage';
     $options = ['query' => ['dataProviderId' => $dataProviderId, 'from' => $from->format('c'), 'to' => $to->format('c'), 'groupBy' => $groupBy, 'limit' => $limit, 'offset' => $offset]];
     $usage = [];
     try {
         $data = null;
         // try to get from cache
         if ($this->cache) {
             $data = $this->cache->get($this->cachePrefix, $uri, $options);
         }
         // load from API
         if (!$data) {
             $data = $this->httpClient->get($uri, $options)->getBody()->getContents();
             if ($this->cache and $data) {
                 $this->cache->put($this->cachePrefix, $uri, $options, $data);
             }
         }
         $usage = json_decode($data);
     } catch (ClientException $e) {
         $response = $e->getResponse();
         $responseBody = $response->getBody()->getContents();
         $responseCode = $response->getStatusCode();
         throw new Exception\ApiException($responseBody, $responseCode);
     }
     return $usage;
 }
开发者ID:paul-schulleri,项目名称:adform-client,代码行数:42,代码来源:DataUsageProvider.php


示例4: AssertForbidden

function AssertForbidden($to, $specifically = 0)
{
    global $loguser, $forbidden;
    if (!isset($forbidden)) {
        $forbidden = explode(" ", $loguser['forbiddens']);
    }
    $caught = 0;
    if (in_array($to, $forbidden)) {
        $caught = 1;
    } else {
        $specific = $to . "[" . $specifically . "]";
        if (in_array($specific, $forbidden)) {
            $caught = 2;
        }
    }
    if ($caught) {
        $not = __("You are not allowed to {0}.");
        $messages = array("addRanks" => __("add new ranks"), "blockLayouts" => __("block layouts"), "deleteComments" => __("delete usercomments"), "editCats" => __("edit the forum categories"), "editForum" => __("edit the forum list"), "editIPBans" => __("edit the IP ban list"), "editMods" => __("edit Local Moderator assignments"), "editMoods" => __("edit your mood avatars"), "editPoRA" => __("edit the PoRA box"), "editPost" => __("edit posts"), "editProfile" => __("edit your profile"), "editSettings" => __("edit the board settings"), "editSmilies" => __("edit the smiley list"), "editThread" => __("edit threads"), "editUser" => __("edit users"), "haveCookie" => __("have a cookie"), "listPosts" => __("see all posts by a given user"), "makeComments" => __("post usercomments"), "makeReply" => __("reply to threads"), "makeThread" => __("start new threads"), "optimize" => __("optimize the tables"), "purgeRevs" => __("purge old revisions"), "recalculate" => __("recalculate the board counters"), "search" => __("use the search function"), "sendPM" => __("send private messages"), "snoopPM" => __("view other users' private messages"), "useUploader" => __("upload files"), "viewAdminRoom" => __("see the admin room"), "viewAvatars" => __("see the avatar library"), "viewCalendar" => __("see the calendar"), "viewForum" => __("view fora"), "viewLKB" => __("see the Last Known Browser table"), "viewMembers" => __("see the memberlist"), "viewOnline" => __("see who's online"), "viewPM" => __("view private messages"), "viewProfile" => __("view user profiles"), "viewRanks" => __("see the rank lists"), "viewRecords" => __("see the top scores and DB usage"), "viewThread" => __("read threads"), "viewUploader" => __("see the uploader"), "vote" => __("vote"));
        $messages2 = array("viewForum" => __("see this forum"), "viewThread" => __("read this thread"), "makeReply" => __("reply in this thread"), "editUser" => __("edit this user"));
        $bucket = "forbiddens";
        include "./lib/pluginloader.php";
        if ($caught == 2 && array_key_exists($to, $messages2)) {
            Kill(format($not, $messages2[$to]), __("Permission denied."));
        }
        Kill(format($not, $messages[$to]), __("Permission denied."));
    }
}
开发者ID:knytrune,项目名称:ABXD,代码行数:27,代码来源:permissions.php


示例5: send

 public function send($errorCode, $data, $more = true, $extra = array(), $execute = true)
 {
     //注意要判断message是否为空。
     $arr = array('errorCode' => (string) $errorCode, 'message' => format($data, $more, $extra));
     $json = CJSON::encode($arr);
     $json = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'unescapedUnicode', $json);
     if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'android') !== FALSE) {
         header('Content-type:application/json;charset=utf-8');
         if ($execute) {
             exit($json);
         } else {
             echo $json;
         }
     } else {
         if (empty($_SERVER['HTTP_USER_AGENT'])) {
             header('Content-type:application/json;charset=utf-8');
             if ($execute) {
                 exit($json);
             } else {
                 echo $json;
             }
         } else {
             header('Content-type:text/html;charset=utf-8');
             Yii::app()->getController()->jsonText = jsonFormat($json);
         }
     }
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:27,代码来源:JsonBehavior.php


示例6: withHTML

 function withHTML()
 {
     if (!$this->desc_html) {
         $this->desc_html = format('product', $this->desc);
         $this->save();
     }
     return $this;
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:8,代码来源:Product.php


示例7: reportFix

function reportFix($what, $aff = -1)
{
    global $fixtime;
    if ($aff = -1) {
        $aff = affectedRows();
    }
    echo $what, " ", format(__("{0} rows affected."), $aff), " time: ", sprintf('%1.3f', usectime() - $fixtime), "<br />";
}
开发者ID:Servault,项目名称:Blargboard,代码行数:8,代码来源:recalc.php


示例8: withHTML

 function withHTML()
 {
     if (!$this->html) {
         $this->html = format('post', $this->body);
         $this->save();
     }
     return $this;
 }
开发者ID:SerdarSanri,项目名称:VaneMart,代码行数:8,代码来源:Post.php


示例9: processObject

 private function processObject($obj)
 {
     $fa = \CLips\get_annotation(get_class($obj), 'Clips\\Formatter');
     if ($fa) {
         return $name . '="' . \format($obj, $fa->value) . '"';
     } else {
         return $this->format((array) $obj);
     }
 }
开发者ID:guitarpoet,项目名称:clips-tool,代码行数:9,代码来源:TagAttributeFormatter.php


示例10: MakeSelect

function MakeSelect($fieldName, $checkedIndex, $choicesList, $extras = "")
{
    $checks[$checkedIndex] = " selected=\"selected\"";
    foreach ($choicesList as $key => $val) {
        $options .= format("\n\t\t\t\t\t\t<option value=\"{0}\"{1}>{2}</option>", $key, $checks[$key], $val);
    }
    $result = format("\n\t\t\t\t\t<select id=\"{0}\" name=\"{0}\" size=\"1\" {1} >{2}\n\t\t\t\t\t</select>", $fieldName, $extras, $options);
    return $result;
}
开发者ID:RoadrunnerWMC,项目名称:ABXD-legacy,代码行数:9,代码来源:editsettings.php


示例11: showUpdates

 function showUpdates()
 {
     $age = $this->checkAge("tweeter", 5);
     if ($age <= 0) {
         $this->gatherTweet();
     }
     $this->getAllByID("tweeter");
     $cached = $this->sql->getNextRow();
     $ret = $cached["cached_contents"];
     return format($ret);
 }
开发者ID:nhandler,项目名称:whube,代码行数:11,代码来源:twitter.php


示例12: format

function format($array)
{
    foreach ($array as $key => $item) {
        if (is_array($item)) {
            $array[$key] = format($item);
        } else {
            $array[$key] = preg_replace(array('/\\*([^*]+)\\*/', '/\\(([^_]+)\\)/', '/\\n\\s*\\n/', '/"([^"]+)"/', '/\\s{2,}/'), array('<strong>\\1</strong>', '<span>\\1</span>', "<br />\n", '<q>\\1</q>', ' '), $item);
        }
    }
    return $array;
}
开发者ID:speed-of-light,项目名称:oath,代码行数:11,代码来源:i18n.php


示例13: findNotPay

 function findNotPay($args)
 {
     $current = (int) $args[0];
     if ($current == 0) {
         $current = 1;
     }
     $arr = array('date_start' => '2015-09-01', 'date_end' => format(timenow(), '-') . ' 23:59:59', 'name' => '', 'pay' => 0);
     $data = $this->load->model('order')->findByPay($arr, array($current, HOSTNAME . 'admin/order/findNotPay/', 15));
     $pagination = $this->db->getPage();
     return $this->load->view('order_notPay', array('orders' => $data, 'pagination' => $pagination));
 }
开发者ID:jinghuizhai,项目名称:ida,代码行数:11,代码来源:order.php


示例14: buildInput

function buildInput($name, $title = '', $type = 'text', $data = '', $extra = '')
{
    $title = $title ? $title : format($name);
    if ($type == 'checkbox' and $data) {
        $checked = " checked='checked'";
    }
    if ($data) {
        $value = " value='{$data}'";
    }
    print "<label for='{$name}'>{$title}</label><input type='{$type}' name='{$name}' id='{$name}'" . $value . $checked . $extra . " /><br />\n";
}
开发者ID:Gninety,项目名称:Microweber,代码行数:11,代码来源:index.php


示例15: err

function err($message, $args = null, $args2 = null)
{
    $message = format(func_get_args());
    echo $message . PHP_EOL;
    $dir = 'reports';
    if (!is_dir($dir)) {
        mkdir($dir, 0777, true);
    }
    $content = $message . str_repeat(PHP_EOL, 2) . str_repeat('=', 70);
    file_put_contents($dir . '/check-coverage.txt', $content);
    return '';
}
开发者ID:miaoxing,项目名称:plugin,代码行数:12,代码来源:check-coverage.php


示例16: logs

function logs($str)
{
    $file = fopen(LOGS . format(timenow(), '_') . '.txt', 'a');
    if (flock($file, LOCK_EX)) {
        //加写锁
        // fputs($file,$string);        //写文件
        fwrite($file, $str . "--" . timenow() . "\n");
        flock($file, LOCK_UN);
        //解锁
    }
    fclose($file);
}
开发者ID:jinghuizhai,项目名称:ida,代码行数:12,代码来源:fun.php


示例17: getOnlineUsersText

function getOnlineUsersText()
{
    global $OnlineUsersFid;
    $refreshCode = "";
    if (!isset($OnlineUsersFid)) {
        $OnlineUsersFid = 0;
    }
    if (Settings::get("ajax")) {
        $refreshCode = format("\n\t\t<script type=\"text/javascript\">\n\t\t\tonlineFID = {0};\n\t\t\twindow.addEventListener(\"load\",  startOnlineUsers, false);\n\t\t</script>\n\t", $OnlineUsersFid);
    }
    $onlineUsers = OnlineUsers($OnlineUsersFid);
    return "<div style=\"min-height:16px;\" id=\"onlineUsers\">{$onlineUsers}</div>{$refreshCode}";
}
开发者ID:Servault,项目名称:Blargboard,代码行数:13,代码来源:onlineusers.php


示例18: endeach

function endeach()
{
    global $each_parameter;
    global $each_param_name;
    $html = ob_get_clean();
    foreach ($each_parameter as $param) {
        if (is_array($param)) {
            echo format($html, $param);
        } else {
            echo format($html, array($each_param_name => $param));
        }
    }
}
开发者ID:boky8zg,项目名称:hsn-new,代码行数:13,代码来源:view.php


示例19: step0

function step0($req)
{
    set_time_limit(0);
    //this avoids timeouts
    $_SESSION["ent_checked"] = array();
    $ent = $_SESSION["ent"];
    if (isset($_SESSION["ent_old"])) {
        $ent_old = $_SESSION["ent_old"];
        $response = format($ent, $ent_old);
    } else {
        $response = format($ent);
    }
    return $response;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:14,代码来源:procedures_retrieve.php


示例20: qwp_tmpl_render_sub_modules

function qwp_tmpl_render_sub_modules()
{
    global $MODULE, $MODULE_URI;
    $nav = C('sub_nav', array());
    $html = '';
    foreach ($nav[$MODULE[0]] as $item) {
        $active = '';
        if ($item[0] == $MODULE_URI) {
            $active = ' class="active"';
        }
        $html .= format('<li{0}><a href="{1}">{2}</a></li>', $active, qwp_uri_module($item[0]), L($item[1]));
    }
    echo $html;
}
开发者ID:steem,项目名称:qwp,代码行数:14,代码来源:admin_nav.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP format4Datepicker函数代码示例发布时间:2022-05-15
下一篇:
PHP form_value函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap