本文整理汇总了PHP中exists函数的典型用法代码示例。如果您正苦于以下问题:PHP exists函数的具体用法?PHP exists怎么用?PHP exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
protected function render()
{
try {
$prop = $this->props;
$services = $prop->service ?: $prop->services;
if ($services) {
$vm = $this->context->getDataBinder()->getViewModel();
$injector = $this->context->injector;
$aliases = preg_split('/\\s+/', $services, -1, PREG_SPLIT_NO_EMPTY);
if (exists($as = $prop->as)) {
if (count($aliases) > 1) {
throw new ComponentException($this, "When using the <kbd>as</kbd> property, you can only specify one value for the <kbd>service</kbd> property");
}
$service = $injector->make($services);
$vm->{$as} = $service;
} else {
foreach ($aliases as $alias) {
$service = $injector->get($alias);
$vm->{$alias} = $service;
}
}
}
} catch (NotFoundException $e) {
throw new ComponentException($this, $e->getMessage());
}
}
示例2: __isset
public function __isset()
{
if (exists($this->color)) {
return TRUE;
}
return FALSE;
}
示例3: getImageUrl
public function getImageUrl($path, array $params = [])
{
if (exists($path)) {
return rtrim(substr($this->urlBuilder->getUrl($path, $params), 1), '?');
}
return '';
}
示例4: getImplementationType
function getImplementationType()
{
global $zuckerreports_config;
if ($zuckerreports_config["team_implementation"] == "auto") {
if (file_exists("modules/Teams/Team.php")) {
return "sugar";
} else {
if (!empty($zuckerreports_config["teams"])) {
return "simple";
} else {
return "none";
}
}
} else {
if ($zuckerreports_config["team_implementation"] == "sugar" && exists("modules/Teams/Team.php")) {
return "sugar";
} else {
if ($zuckerreports_config["team_implementation"] == "simple") {
return "simple";
} else {
return "none";
}
}
}
}
示例5: evaluate
protected function evaluate()
{
$prop = $this->props;
$np = Parser::NAMELESS_PROP;
if (isset($prop->{$np})) {
if ($prop->{$np}) {
// if ($prop->getComputed($np))
return $this->getChildren();
}
return $this->getChildren('else');
}
$v = $prop->get('value');
$not = $prop->not;
if (exists($prop->matches)) {
if (preg_match("%{$prop->matches}%", $v) xor $not) {
return $this->getChildren();
}
return $this->getChildren('else');
}
if ($prop->case) {
foreach ($prop->case as $param) {
if ($v == $param->props->is) {
return $param->getChildren();
}
}
return $this->getChildren('else');
}
if (toBool($v) xor $not) {
return $this->getChildren();
}
return $this->getChildren('else');
}
示例6: getError
private function getError($item)
{
if (exists($this->errors[$item])) {
return $this->errors[$item];
} else {
return "";
}
}
示例7: makeBody
function makeBody($content = '', $stream = 'php://memory')
{
$s = new Stream($stream, 'wb+');
if (exists($content)) {
$s->write($content);
}
return $s;
}
示例8: isLoggedIn
function isLoggedIn()
{
if (!empty($_SESSION['logged_in']) && exists($connection, 'user_id', 'users', 'user_id', $_SESSION['logged_in']) == true) {
return true;
} else {
return false;
}
}
示例9: testUnPlug
public function testUnPlug()
{
$class = __NAMESPACE__ . '\\FakePlug';
plug('fake', [_CLASS => $class]);
$this->assertTrue(exists('fake', 'PlugIn'));
unPlug('fake');
$this->assertFalse(exists('fake', 'PlugIn'));
}
示例10: render
protected function render()
{
$prop = $this->props;
$scopeProps = $this->getDataBinder()->getProps();
$name = $prop->name;
if (isset($scopeProps) && !exists($scopeProps->{$name})) {
$scopeProps->{$name} = $prop->default;
}
}
示例11: render
/**
* Registers a stylesheet on the Page.
*/
protected function render()
{
$prop = $this->props;
if (exists($prop->src)) {
$this->context->getAssetsService()->addStylesheet($prop->src, $this->props->prepend);
} else {
if ($this->hasChildren()) {
$this->context->getAssetsService()->addInlineCss($this, $prop->name, $this->props->prepend);
}
}
}
示例12: viewModel
protected function viewModel(ViewModel $viewModel)
{
$settings = $viewModel->adminSettings = $this->adminSettings;
if ($settings->showMenu()) {
$target = $settings->topMenuTarget();
$viewModel->topMenu = exists($target) ? isset($this->navigation[$target]) ? $this->navigation[$target] : null : $this->navigation;
}
$viewModel->sideMenu = get($this->navigation->getCurrentTrail($settings->sideMenuOffset()), 0);
$user = $this->session->user();
$viewModel->devMode = $user && $user->roleField() == UserInterface::USER_ROLE_DEVELOPER;
}
示例13: test_exists
function test_exists()
{
$this->assertTrue(exists($GLOBALS['_name']));
$foo = '';
$bar = array();
$this->assertFalse(exists($foo));
$this->assertFalse(exists($bar));
$this->assertEqual(use_default('', 'foo'), 'foo');
$this->assertEqual(use_default('bar', 'foo'), 'bar');
$this->assertNotEqual(use_default('bar', 'foo'), 'foo');
$this->assertNotEqual(use_default('', 'foo'), '');
}
示例14: render
protected function render()
{
$viewModel = $this->getViewModel();
$prop = $this->props;
$count = $prop->get('count', -1);
if (exists($prop->each)) {
$this->parseIteratorExp($prop->each, $idxVar, $itVar);
} else {
$idxVar = $itVar = null;
}
if (!is_null($for = $prop->of)) {
$first = true;
foreach ($for as $i => $v) {
if ($idxVar) {
$viewModel->{$idxVar} = $i;
}
$viewModel->{$itVar} = $v;
if ($first) {
$first = false;
$this->runChildren('header');
} else {
$this->runChildren('glue');
}
$this->runChildren();
if (!--$count) {
break;
}
}
if ($first) {
$this->runChildren('noData');
} else {
$this->runChildren('footer');
}
return;
}
if ($count > 0) {
for ($i = 0; $i < $count; ++$i) {
$viewModel->{$idxVar} = $viewModel->{$itVar} = $i;
if ($i == 0) {
$this->runChildren('header');
} else {
$this->runChildren('glue');
}
$this->runChildren();
}
if ($i) {
$this->runChildren('footer');
return;
}
}
$this->runChildren('noData');
}
示例15: addInlineScript
/**
* Adds an inline script to the HEAD section of the page.
*
* @param string|RenderableInterface $code Javascript code without the script tags.
* @param string $name An identifier for the script, to prevent duplication.
* When multiple scripts with the same name are added, only the last one is
* considered.
* @param bool $prepend If true, prepend to current list instead of appending.
* @return $this
*/
function addInlineScript($code, $name = null, $prepend = false)
{
if (exists($name)) {
$this->assets->inlineScripts[$name] = $code;
} else {
if ($prepend) {
array_unshift($this->assets->inlineScripts, $code);
} else {
$this->assets->inlineScripts[] = $code;
}
}
return $this;
}