本文整理汇总了PHP中f函数的典型用法代码示例。如果您正苦于以下问题:PHP f函数的具体用法?PHP f怎么用?PHP f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticateRemoteUser
public function authenticateRemoteUser($remoteUser)
{
$app = \App::getInstance();
$authorized = f('auth.remoteAuthorize', $remoteUser);
if ($authorized) {
$users = \Norm\Norm::factory('User');
$user = $users->findOne(array('username' => $remoteUser['username']));
if (is_null($user)) {
$user = $users->newInstance();
$user['username'] = $remoteUser['username'];
$user['first_name'] = $remoteUser['first_name'];
$user['last_name'] = $remoteUser['last_name'];
$user['birth_date'] = $remoteUser['birth_date'];
$user['birth_place'] = $remoteUser['birth_place'];
}
if (!empty($remoteUser['normalized_username'])) {
$user['normalized_username'] = $remoteUser['normalized_username'];
}
$user['email'] = $remoteUser['email'];
$user['sso_account_id'] = $remoteUser['$id'];
$user->save();
} else {
throw new \Exception('You are unauthorized to access this application. Please contact administrator.');
}
return $user->toArray();
}
示例2: doError
public function doError($exception = null)
{
function setError($code, $msg)
{
http_response_code($code);
return sprintf("%s%s", is_numeric($code) ? "<span style=\"color: red;\">{$code}</span> " : '', $msg);
}
function f($e)
{
if ($e instanceof ForbiddenException) {
return setError(403, 'FORBIDDEN');
} else {
if ($e instanceof WrongMethodException) {
return setError(405, 'WRONG METHOD');
} else {
if ($e instanceof BadRequestException) {
return setError(400, 'BAD REQUEST');
} else {
if ($e instanceof NotFoundException) {
return setError(404, 'NOT FOUND');
} else {
return setError(500, 'INTERNAL SERVER ERROR');
}
}
}
}
}
return '<div style="text-align: center; padding-top: 20px;">' . f($exception) . '</div>';
}
示例3: getFields
/**
* 获取表字段信息
*
* @param string $table
*
* @return array|bool|void
*/
public function getFields($table)
{
$name = c('database.database') . '.' . $table;
//字段缓存
if (!c('app.debug') && f($name, '[get]', 0, ROOT_PATH . '/storage/field')) {
$data = f($name, '[get]', 0, ROOT_PATH . '/storage/cache/field');
} else {
$sql = "show columns from " . c('database.prefix') . $table;
if (!($result = Db::query($sql))) {
return [];
}
$data = [];
foreach ((array) $result as $res) {
$f['field'] = $res['Field'];
$f['type'] = $res['Type'];
$f['null'] = $res['Null'];
$f['field'] = $res['Field'];
$f['key'] = $res['Key'] == "PRI" && $res['Extra'] || $res['Key'] == "PRI";
$f['default'] = $res['Default'];
$f['extra'] = $res['Extra'];
$data[$res['Field']] = $f;
}
f($name, $data, 0, ROOT_PATH . '/storage/field');
}
return $data;
}
示例4: move
/**
* @role update
*/
public function move()
{
$page = StaticPage::getInstanceById((int) $this->request->get('id'), StaticPage::LOAD_DATA);
// update parent
if ($this->request->get('parent')) {
$parent = StaticPage::getInstanceById((int) $this->request->get('parent'), StaticPage::LOAD_DATA);
} else {
$parent = null;
}
$page->parent->set($parent);
$page->save();
// update order
$f = new ARUpdateFilter();
if ($parent) {
$f->setCondition(eq(f('StaticPage.parentID'), $parent->getID()));
} else {
$f->setCondition(new IsNullCond(f('StaticPage.parentID')));
}
$f->addModifier('StaticPage.position', new ARExpressionHandle('position+2'));
if ($this->request->get('previous')) {
$previous = StaticPage::getInstanceById((int) $this->request->get('previous'), StaticPage::LOAD_DATA);
$position = $previous->position->get();
$f->mergeCondition(gt(f('StaticPage.position'), $position));
$page->position->set($position + 1);
} else {
$previous = null;
$page->position->set(1);
}
ActiveRecordModel::updateRecordSet('StaticPage', $f);
$page->save();
return new JSONResponse(array(), 'success', $this->translate('_pages_were_successfully_reordered'));
}
示例5: set
public function set(array $delete, array $cookies)
{
$pending = array();
$f = function ($spec, $key, $val) use($pending) {
if (!array_key_exists($spec, $pending)) {
$pending[$spec] = array();
}
$pending[$spec][$key] = $val;
};
foreach ($delete as $key) {
f(null, $key, '');
}
foreach ($cookies as $key => $data) {
list($val, $spec) = $data;
$f($spec, $key, $val);
}
$callback = $this->callback;
foreach ($pending as $spec => $data) {
if ($spec === null) {
$spec = new CookieSpec();
}
$flags = $spec->secure ? extCookie::SECURE : 0;
$flags += $spec->httponly ? extCookie::HTTPONLY : 0;
$httpCookie = new extCookie(null, $flags);
$httpCookie->setCookies($data);
$httpCookie->setExpires($spec->expire);
$httpCookie->setPath($spec->path);
$httpCookie->setDomain($spec->domain);
$callback($httpCookie->toString());
}
return true;
}
示例6: rss
function rss()
{
$url = f('url');
if (!$url) {
$url = 'http://java5000.blogspot.com/feeds/posts/default?alt=rss';
}
require ROOT . 'lib/rss/lastRSS.php';
$rss = new lastRSS();
$str = $this->url2str($url, 1);
if (!$str) {
$data = $this->fmodel('rss')->peek(array('url' => $url));
$data['valid'] = 2;
$this->fmodel('rss')->save($data);
$str = "";
} else {
cacheme($url, $str);
}
$result = $rss->ParseStr($str);
if ($result["encoding"] && strcasecmp($result["encoding"], "utf-8") != 0) {
$result = $rss->ParseStr(mb_convert_encoding($str, "UTF-8", $result["encoding"]));
}
foreach ($result["items"] as &$i) {
$i["description"] = html_entity_decode($i["description"]);
$i["description"] = preg_replace('/< *br *[\\/]?>/', "\n", $i["description"]);
$i["description"] = preg_replace('|href=("?)|i', 'target=_blank href=${1}/self/out/rd?url=', $i["description"]);
$i["link"] = preg_replace('/>$/', "", $i["link"]);
if (!preg_match('/^https?\\:/', $i["link"])) {
$i["link"] = "http://www.google.com/search?q=" . urlencode($i["title"]);
}
}
$this->sv("rssresult", $result);
$rsslist = $this->fmodel('rss')->peeks(array('valid' => 1));
$this->sv("rssfeed", array_reverse($rsslist));
}
示例7: replaceFields
private function replaceFields($item)
{
// SEARCH {} IN TEMPLATE
preg_match_all('`{([A-Za-z0-9\\._\\x7f-\\xff]+?)}`', $this->tpl, $results);
if (!$results) {
return;
}
$results[0] = array_unique($results[0]);
$results[1] = array_unique($results[1]);
foreach ($results[0] as $key => $value) {
// ONLY FOR PHPTHUMB AND JCROP
if ($results[1][$key] == 'phptParams') {
if ($item['cropCords']) {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getCropParams($item['cropCords']), $this->copyTpl);
} else {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getParams(), $this->copyTpl);
}
}
// RETURN WIDTH AND HEIGHT ATTR OF IMG
if ($results[1][$key] == 'imgSize') {
$this->copyTpl = preg_replace('/' . $value . '/', $this->phpt->getImgDimentions(), $this->copyTpl);
}
// ITERATE ALL {} FOUND IN TEMPLATE
$this->copyTpl = preg_replace('/' . $value . '/', f($item[$results[1][$key]]), $this->copyTpl);
}
}
示例8: foo
function foo()
{
$obj = new C();
$obj->a = f();
$obj->b = new C();
$obj->b->a = f();
}
示例9: foo
function foo($a)
{
(yield 1);
foreach ((array) f($a) as $x) {
var_dump('i:' . $x);
}
}
示例10: fetch
function fetch($tpl = '')
{
// 模板文件
T('POEM_COMPILE_TIME');
$tpl = $this->parseTpl($tpl);
$filekey = str_replace(APP_PATH, '', $tpl);
// 文件名 Home/Index/index.html
$c_w_v_tpl = f($filekey, '', 2);
// 判断是否存在
if (APP_DEBUG || $c_w_v_tpl === false) {
$content = file_get_contents($tpl);
// 开启页面布局
if (($layfile = config('layout')) && config('layout_on') === true) {
$layfile = $this->parseTpl($layfile);
$content = str_replace('{__LAYOUT__}', $content, file_get_contents($layfile));
}
$content = $this->compiler($content);
// 模板编译
$c_w_v_tpl = f($filekey, $content);
// F($filekey, php_strip_whitespace($c_w_v_tpl) ); // 去掉空格什么的
}
T('POEM_COMPILE_TIME', 0);
// 模板变量
if (!empty($this->html_vars)) {
extract($this->html_vars);
}
$this->html_vars = array();
// 清空
// 缓冲区
ob_start();
ob_implicit_flush(0);
include $c_w_v_tpl;
// 获取并清空缓存
return ob_get_clean();
}
示例11: get_aid_by_name
function get_aid_by_name($name)
{
$s = q("SELECT * FROM aid WHERE name = '" . clean_query($name) . "' limit 1;");
if (a() > 0) {
return f($s);
}
}
示例12: __construct
public function __construct()
{
Language::read("common");
Language::read("microshop");
if (c("microshop_isuse") != "1") {
header("location: " . SiteUrl);
exit;
}
Tpl::setdir("default");
self::cp();
Tpl::setlayout("microshop_layout");
if ($_GET['column'] && strtoupper(CHARSET) == "GBK") {
$GLOBALS['_GET'] = Language::getgbk($_GET);
}
Tpl::output("nav_list", ($nav = f("nav")) ? $nav : h("nav", TRUE, "file"));
$search_type = array();
$search_type['goods'] = Language::get("nc_microshop_goods");
$search_type['personal'] = Language::get("nc_microshop_personal");
$search_type['store'] = Language::get("nc_microshop_store");
Tpl::output("search_type", $search_type);
if (!empty($_SESSION['member_id']) || 0 < intval($_SESSION['member_id'])) {
self::get_member_avatar($_SESSION['member_id']);
}
if (!c("site_status")) {
halt(c("closed_reason"));
}
Tpl::output("html_title", Language::get("nc_microshop") . "-" . c("site_name"));
Tpl::output("seo_keywords", c("microshop_seo_keywords"));
Tpl::output("seo_description", c("microshop_seo_description"));
$this->queryCart();
}
示例13: f
function f($a, $b)
{
echo number_format($a, 0, '', '') . '<br>' . number_format($b, 0, '', '') . '<br>';
$a = $a + $b;
$b = $a + $b;
f($a, $b);
}
示例14: pr
function pr(...$args)
{
return f(function ($a) {
echo $a, "\n";
return $a;
}, ...$args);
}
示例15: getSelectFilter
public function getSelectFilter($disableFilters = false)
{
$selectFilter = $this->category->getProductsFilter($this, false);
$selectFilter->merge($this->productFilter);
$cond = null;
$list = array();
// group filters by class
foreach ($this->filters as $filter) {
if ($disableFilters && !$filter instanceof SearchFilter) {
continue;
}
$id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : '';
$list[get_class($filter) . '_' . $id][] = $filter->getCondition();
$filter->defineJoin($selectFilter);
}
// convert filter group to OrChainCondition
foreach ($list as &$filterGroup) {
$filterGroup = new OrChainCondition($filterGroup);
}
if ($fCond = $selectFilter->getCondition()) {
$list[] = $fCond;
}
$selectFilter->setCondition(new AndChainCondition($list));
// all merged with and
$selectFilter->setOrder(f('Product.ID'), 'DESC');
ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter);
return $selectFilter;
}