本文整理汇总了PHP中before函数的典型用法代码示例。如果您正苦于以下问题:PHP before函数的具体用法?PHP before怎么用?PHP before使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了before函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
function handle($uri = '')
{
try {
if (($matched = dispatch($uri)) != null) {
if (!before()) {
$handler = $matched['handler'];
if (!empty($matched['options']['router'])) {
$handler = call_user_func($handler, $matched);
}
if (!empty($matched['options']['create'])) {
$controllerClass = $handler[0];
$handler[0] = new $controllerClass();
}
if (isset($matched['params'])) {
call_user_func_array($handler, $matched['params']);
} else {
call_user_func_array($handler, $matched['segments']);
}
after();
}
} else {
notFound();
}
finish();
} catch (Exception $e) {
error_log($e->getMessage());
error_log($e->getTraceAsString());
}
exit;
}
示例2: authorize
function authorize($data = null)
{
global $authorized;
before();
?>
<div id="xicl-error" style="">
<table id="xicl-error-content"><tr><td>
<?php
login();
// показываем форму входа/выхода
?>
<?php
if (_has('message')) {
?>
<p class="message"><?php
echo _data('message');
?>
</p>
<?php
}
?>
</td></tr></table>
<a href="./" id="xicl-error-home" title="на главную"> </a>
</div>
<?php
after();
die;
// прекратить дальнейшую работу
}
示例3: getPlayerSkin
function getPlayerSkin($input, $list)
{
if ($input !== '[]') {
$name = after('[`', $input);
$name = before('`', $name);
if (in_array($name, $list)) {
return $name;
} else {
return "Default";
}
} else {
return "Default";
}
}
示例4: not_found
/**
* 404 error page.
*/
function not_found($errno, $errstr, $errfile = null, $errline = null)
{
if (strpos($errstr, '/public/soft_images/') !== false) {
render_file('public/img/down.png');
return;
}
before();
set('errno', $errno);
set('errstr', $errstr);
set('errfile', $errfile);
set('errline', $errline);
layout('layout.php');
return html('404.php');
}
示例5: fail
function fail($message)
{
global $messages;
before();
?>
<div id="xicl-error" style="">
<table id="xicl-error-content"><tr><td>
<p class="message error"><?php
echo is_string($message) ? $message : (is_int($message) ? $messages[$message] : 'unknown param for fail page');
?>
</p>
</td></tr></table>
<a href="<?php
echo ServerRoot;
?>
" id="xicl-error-home" title="на главную"> </a>
</div>
<?php
after();
die;
// прекратить дальнейшую работу
}
示例6: gensuite
public static function gensuite($config = array(), $current_depth = 1)
{
$config = array_merge(array('befores' => 0, 'before_alls' => 0, 'afters' => 0, 'after_alls' => 0, 'tests' => 1, 'depth' => 0, 'describes' => array('L', 'R'), 'callbacks' => array('it' => function ($ctx) {
expect(true)->to->eql(true);
}, 'before' => function ($ctx) {
$ctx->value = 3;
}, 'before_all' => function ($ctx) {
$ctx->value = 5;
}, 'after' => function ($ctx) {
$ctx->value = 7;
}, 'after_all' => function ($ctx) {
$ctx->value = 11;
})), $config);
if ($config['depth'] == 0) {
return;
}
foreach ($config['describes'] as $side) {
describe("Level {$side}{$current_depth}", function ($ctx) use($config, $current_depth) {
for ($i = 1; $i <= $config['tests']; $i++) {
it("nested {$i}", $config['callbacks']['it']);
}
for ($i = 1; $i <= $config['befores']; $i++) {
before($config['callbacks']['before']);
}
for ($i = 1; $i <= $config['before_alls']; $i++) {
before_all($config['callbacks']['before_all']);
}
for ($i = 1; $i <= $config['after_alls']; $i++) {
after_all($config['callbacks']['after_all']);
}
for ($i = 1; $i <= $config['afters']; $i++) {
after($config['callbacks']['after']);
}
$config['depth']--;
Util::gensuite($config, $current_depth + 1);
});
}
}
示例7: fddbSuche
function fddbSuche($gtin)
{
//$gtin = "4388844009943";
$gtin = preg_replace('/[^0-9]+/', '', $gtin);
$data = curlData("http://fddb.mobi/search/?lang=de&cat=mobile-de&search=" . $gtin);
$resultblock = between("<!-- %sresultblock% //-->", "<!-- %eresultblock% //-->", $data);
$link = between("window.location.href = '", "';", $data);
$area = between("<b>100 g:</b>", "<b>1 Packung:</b>", $data);
if ($link != false && strlen($gtin) >= 13) {
$werte = array("energy" => preg_replace('/[^0-9,.]+/', '', before("(", $area)), "calories" => preg_replace('/[^0-9,.]+/', '', between("(", ")", $area)), "fat" => preg_replace('/[^0-9,.]+/', '', between("Fett: ", "KH:", $area)), "carbonhydrate" => preg_replace('/[^0-9,.]+/', '', between("KH: ", "<br>", $area)));
//$werte = array("Energie", "Energie1", "Fett", "Kohlenhydrate");
$naerhwerte = "";
foreach ($werte as $key => $value) {
$naerhwerte[$key]["value"] = preg_replace('/[^0-9]+/', '', $werte[$key]);
$naerhwerte[$key]["currencie"] = preg_replace('/[^a-zA-Z]+/', '', $werte[$key]);
}
$result = array("sourecName" => "fddb", "link" => $link, "gtin" => $gtin, "nutriTable" => $werte, "titel" => between("<a href='" . $link . "'><b>", '</b></a>', $resultblock));
$graph = new EasyRdf_Graph();
$namespace = new EasyRdf_Namespace();
$namespace->set('rezept', "http://manke-hosting.de/ns-syntax#");
buildTree($graph, $result["link"], $result, 'rezept');
echo $graph->serialise("turtle");
}
}
示例8: before
before(function () use(&$console, &$spec) {
$console = new Console(array(), 'php://output');
$console->parseArguments();
$suite = new Suite('test', function () {
});
$spec = new Spec('testspec', function () {
}, $suite);
});
it('implements the ReporterInterface', function () use(&$console) {
$reporter = new SpecReporter($console);
expect($reporter instanceof ReporterInterface)->toBeTrue();
});
context('beforeSuite', function () use(&$console) {
$reporter = null;
before(function () use(&$console, &$reporter) {
$reporter = new SpecReporter($console);
});
it('prints the suite title', function () use(&$reporter) {
$beforeSuite = function () use(&$reporter) {
$suite = new Suite('test suite', function () {
});
$reporter->beforeSuite($suite);
};
expect($beforeSuite)->toPrint(PHP_EOL . "test suite" . PHP_EOL);
});
it('pads nested suites', function () use(&$reporter) {
$beforeSuite = function () use(&$reporter) {
$suite = new Suite('test suite', function () {
});
$reporter->beforeSuite($suite);
};
示例9: describe
<?php
namespace kahlan\spec\suite\analysis;
use kahlan\analysis\Inspector;
describe("Inspector", function () {
before(function () {
$this->class = 'kahlan\\spec\\fixture\\analysis\\SampleClass';
});
describe('::inspect()', function () {
it("gets the reflexion layer of a class", function () {
$inspector = Inspector::inspect($this->class);
expect($inspector)->toBeAnInstanceOf('ReflectionClass');
expect($inspector->name)->toBe($this->class);
});
});
describe('::parameters()', function () {
it("gets method's parameters details", function () {
$inspector = Inspector::parameters($this->class, 'parametersExample');
expect($inspector)->toBeA('array');
$param2 = next($inspector);
expect($param2)->toBeAnInstanceOf('ReflectionParameter');
expect($param2->getName())->toBe('b');
expect($param2->getDefaultValue())->toBe(100);
$param3 = next($inspector);
expect($param3)->toBeAnInstanceOf('ReflectionParameter');
expect($param3->getName())->toBe('c');
expect($param3->getDefaultValue())->toBe('abc');
$param4 = next($inspector);
expect($param4)->toBeAnInstanceOf('ReflectionParameter');
expect($param4->getName())->toBe('d');
示例10: __construct
use pho\Suite\Suite;
use pho\Runnable\Spec;
use pho\Runnable\Runnable;
use pho\Exception\ErrorException;
use pho\Exception\ExpectationException;
class MockRunnable extends Runnable
{
public function __construct(\Closure $closure, Suite $suite)
{
$this->suite = $suite;
$this->closure = $closure->bindTo($suite);
}
}
describe('Runnable', function () {
before(function () {
$this->suite = new Suite('TestSuite', function () {
});
});
context('run', function () {
it('catches and stores errors', function () {
$closure = function () {
trigger_error('TestError', E_USER_NOTICE);
};
$runnable = new MockRunnable($closure, $this->suite);
$runnable->run();
expect($runnable->exception->getType())->toEqual('E_USER_NOTICE');
});
it('catches and stores ExpectationExceptions', function () {
$closure = function () {
throw new ExpectationException('test');
};
$runnable = new MockRunnable($closure, $this->suite);
示例11: beforeEach
beforeEach(function () {
$this->bar = 1;
});
it("can access variable from the parent scope", function () {
expect($this->bar)->toBe(1);
});
});
});
describe("skipIf", function () {
it("returns none if provided false/null", function () {
expect(skipIf(false))->toBe(null);
});
$executed = 0;
context("when used in a scope", function () use(&$executed) {
before(function () {
skipIf(true);
});
it("skips this spec", function () use(&$executed) {
expect(true)->toBe(false);
$executed++;
});
it("skips this spec too", function () use(&$executed) {
expect(true)->toBe(false);
$executed++;
});
});
it("expects that no spec have been runned", function () use(&$executed) {
expect($executed)->toBe(0);
});
context("when used in a spec", function () use(&$executed) {
it("skips this spec", function () use(&$executed) {
示例12: describe
namespace Kahlan\Spec\Suite\Matcher;
use Kahlan\Jit\Interceptor;
use Kahlan\Jit\Patcher\Pointcut;
use Kahlan\Matcher\ToReceiveNext;
use Kahlan\Spec\Fixture\Plugin\Pointcut\Foo;
describe("toReceiveNext", function () {
describe("::match()", function () {
/**
* Save current & reinitialize the Interceptor class.
*/
before(function () {
$this->previous = Interceptor::instance();
Interceptor::unpatch();
$cachePath = rtrim(sys_get_temp_dir(), DS) . DS . 'kahlan';
$include = ['Kahlan\\Spec\\'];
$interceptor = Interceptor::patch(compact('include', 'cachePath'));
$interceptor->patchers()->add('pointcut', new Pointcut());
});
/**
* Restore Interceptor class.
*/
after(function () {
Interceptor::load($this->previous);
});
it("expects called methods to be called in a defined order", function () {
$foo = new Foo();
expect($foo)->toReceive('message');
expect($foo)->toReceiveNext('::version');
expect($foo)->toReceiveNext('bar');
$foo->message();
示例13: describe
<?php
describe("Command Generator Command", function () {
before(function () {
$this->app = (new Siphon\Application())->boot();
$this->app['directory']->create($this->app->basePath('app'));
$this->app['directory']->create($this->app->basePath('app/Command'));
});
after(function () {
$this->app['directory']->delete($this->app->basePath('app'));
});
describe("->handle()", function () {
it("generates a new controller class", function () {
$this->app['console']->call('generate:command', ['class' => 'Foo']);
$file = $this->app->basePath('app/Command/FooCommand.php');
$content = file_get_contents($file);
expect(file_exists($file))->toBe(true);
expect(strpos($content, 'namespace Siphon\\Command'))->toBeA('integer');
expect(strpos($content, 'class FooCommand extends Command'))->toBeA('integer');
});
});
});
示例14: describe
namespace Kahlan\Spec\Jit\Suite;
use Kahlan\Dir\Dir;
use Kahlan\Jit\JitException;
use Kahlan\Jit\Patchers;
use Kahlan\Jit\Interceptor;
use Kahlan\Plugin\Stub;
use Kahlan\Spec\Proxy\Autoloader;
use Kahlan\Spec\Mock\Patcher;
describe("Interceptor", function () {
before(function () {
$this->previous = Interceptor::instance();
Interceptor::unpatch();
$this->composer = Interceptor::composer();
skipIf(!$this->composer);
$composer = clone $this->composer[0];
$this->autoloader = new Autoloader($composer);
spl_autoload_register([$this->autoloader, 'loadClass']);
spl_autoload_unregister($this->composer);
$this->cachePath = Dir::tempnam(null, 'cache');
});
afterEach(function () {
Interceptor::unpatch();
});
after(function () {
spl_autoload_register($this->composer);
spl_autoload_unregister([$this->autoloader, 'loadClass']);
Dir::remove($this->cachePath);
Interceptor::load($this->previous);
});
describe("::patch()", function () {
示例15: describe
// });
// describe('Record', function () {
// xit('TODO', function ($db) {});
// });
// describe('Result', function () {
// xit('TODO', function ($db) {});
// });
// describe('Table', function () {
// xit('TODO', function ($db) {});
// });
// });
describe('Helpers', function () {
describe('hydrate()', function () {
before(function ($db) {
$db->reset()->create('a', array('id' => 'primary_key', 'x' => 'integer'));
$db->a->insert(array('x' => 123));
$db->a->insert(array('x' => 456));
let('a', $db->a);
});
it('should has consistency', function ($a) {
expect($a->count())->toEqual(2);
expect($a->all())->toBeArray();
});
describe('columns', function () {
it('should be able to migrate', function ($a) {
\Grocery\Helpers::hydrate($a, array('x' => 'string'));
$b = $a->columns();
expect($b['x']['type'])->toEqual('string');
});
it('should maintain consistency', function ($a) {
$test = $a->all();
expect($test[0]->x)->toEqual(123);