当前位置: 首页>>代码示例>>PHP>>正文


PHP format函数代码示例

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


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


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