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

PHP before函数代码示例

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

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



在下文中一共展示了before函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:rivetweb,项目名称:old-php-seomonitor,代码行数:30,代码来源:flacon.php


示例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="на главную">&nbsp;</a>
    </div>
<?php 
    after();
    die;
    // прекратить дальнейшую работу
}
开发者ID:bearf,项目名称:xicl-web-interface,代码行数:29,代码来源:authorize.php


示例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";
    }
}
开发者ID:GlitchedMan,项目名称:CyberWorks,代码行数:14,代码来源:editPlayer.php


示例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');
}
开发者ID:nsystem1,项目名称:leaderboard,代码行数:17,代码来源:index.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="на главную">&nbsp;</a>
    </div>
<?php 
    after();
    die;
    // прекратить дальнейшую работу
}
开发者ID:bearf,项目名称:xicl-web-interface,代码行数:22,代码来源:fail.php


示例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);
         });
     }
 }
开发者ID:aaron-em,项目名称:matura,代码行数:38,代码来源:Util.php


示例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");
    }
}
开发者ID:RaphaelManke,项目名称:chefkochWrapperToRDF,代码行数:24,代码来源:fddbSuche.php


示例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);
         };
开发者ID:ciarand,项目名称:pho,代码行数:31,代码来源:SpecReporterSpec.php


示例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');
开发者ID:nurka1109,项目名称:kahlan,代码行数:31,代码来源:InspectorSpec.php


示例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);
开发者ID:gsouf,项目名称:pho,代码行数:32,代码来源:RunnableSpec.php


示例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) {
开发者ID:Ilyes512,项目名称:kahlan,代码行数:31,代码来源:ScopeSpec.php


示例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();
开发者ID:Ilyes512,项目名称:kahlan,代码行数:31,代码来源:ToReceiveNextSpec.php


示例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');
        });
    });
});
开发者ID:MikeGeorgeff,项目名称:siphon,代码行数:22,代码来源:CommandGenerateCommandSpec.php


示例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 () {
开发者ID:Ilyes512,项目名称:kahlan,代码行数:31,代码来源:InterceptorSpec.php


示例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);
开发者ID:rakesh-mohanta,项目名称:grocery,代码行数:32,代码来源:all-spec.php


示例16: describe

        return;
    }
}
describe('AbstractReporter', function () {
    $console = new Console(array(), 'php://output');
    $console->parseArguments();
    $reporter = new MockReporter($console);
    $printContents = null;
    context('afterRun', function () use(&$reporter, &$printContents) {
        before(function () use(&$reporter, &$printContents) {
            // Add a spec and run corresponding reporter hooks
            $suite = new Suite('test', function () {
            });
            $spec = new Spec('testspec', function () {
            }, $suite);
            $reporter->beforeSpec($spec);
            $reporter->afterSpec($spec);
            ob_start();
            $reporter->afterRun();
            $printContents = ob_get_contents();
            ob_end_clean();
        });
        it('prints the running time', function () use(&$printContents) {
            // TODO: Update once pattern matching is added
            $print = $printContents;
            expect($print)->toContain('Finished in');
            expect($print)->toContain('seconds');
        });
        it('prints the number of specs and failures', function () use(&$printContents) {
            expect($printContents)->toContain('1 spec, 0 failures');
        });
开发者ID:ciarand,项目名称:pho,代码行数:31,代码来源:AbstractReporterSpec.php


示例17: ifFileIsADuplicate

function ifFileIsADuplicate($testFileName, $fileNameWithoutType)
{
    $fileName = before('.', $testFileName);
    //remove last 4 characters
    $fileType = after('.', $testFileName);
    //save last 3 characters
    // $testFileName = $convertedData;
    // $fileName = before('.', $convertedData);
    // $fileType = after('.', $convertedData);
    $a = 1;
    while (file_exists($testFileName) == 'true') {
        $testFileName = $fileName . '_' . $a . '.' . $fileType;
        // return new file name and repeat until unique
        $a++;
    }
    return $testFileName;
}
开发者ID:vortexcoaching,项目名称:MQP_Alchemy__Truth,代码行数:17,代码来源:testfunctions2confirmed.blade.php


示例18: find_route

function find_route($method, $route, \Closure $callback)
{
    if ($_SERVER['REQUEST_METHOD'] === $method) {
        if (!empty($_SERVER['QUERY_STRING'])) {
            $url = substr($_SERVER['REQUEST_URI'], 0, -(strlen($_SERVER['QUERY_STRING']) + 1));
        } else {
            $url = $_SERVER['REQUEST_URI'];
        }
        $params = array();
        if (url_match($route, $url, $params)) {
            before($route);
            \call_user_func_array($callback, $params);
            exit;
        }
    }
}
开发者ID:mrjovanovic,项目名称:miniflux,代码行数:16,代码来源:Router.php


示例19: before

<?php

/*
 * Created by IntelliJ IDEA.
 * User: EgaLabs (c) 2015
 * Date: 26/05/2015
 * Time: 20:23
 */
namespace Matura\Tests\Hashing;

use Ignizr\URI\HTTPScheme;
global $uri;
$uri = "https://www.egalabs.io/register?to=http%3A%2F%2Fcdn.egalabs.io%2Fwelcome#who-we-are";
before(function ($ctx) use($uri) {
    $ctx->uri = $uri;
    $ctx->http_scheme = new HTTPScheme($uri);
});
开发者ID:egalabs,项目名称:ignizr,代码行数:17,代码来源:URISetup.php


示例20: before

        before(function ($ctx) {
            $ctx->test = $ctx->suite->find('Suite:Fixture:TestMethod');
        });
        it('should be a TestMethod', function ($ctx) {
            expect($ctx->test)->to->be->a('Matura\\Blocks\\Methods\\TestMethod');
        });
        it('should have the correct parent Block', function ($ctx) {
            expect($ctx->test->parentBlock())->to->be->a('Matura\\Blocks\\Describe');
        });
    });
    describe('BeforeHook', function ($ctx) {
        before(function ($ctx) {
            $ctx->describe = $ctx->suite->find('Suite:Fixture');
        });
        it('should have 1 BeforeHook', function ($ctx) {
            $befores = $ctx->describe->befores();
            expect($befores)->to->have->length(1);
            expect($befores[0])->to->be->a('Matura\\Blocks\\Methods\\BeforeHook');
        });
    });
    describe('BeforeAllHook', function ($ctx) {
        before(function ($ctx) {
            $ctx->describe = $ctx->suite->find('Suite:Fixture');
        });
        it('should have 1 BeforeAllHook', function ($ctx) {
            $before_alls = $ctx->describe->beforeAlls();
            expect($before_alls)->to->have->length(1);
            expect($before_alls[0])->to->be->a('Matura\\Blocks\\Methods\\BeforeAllHook');
        });
    });
});
开发者ID:aaron-em,项目名称:matura,代码行数:31,代码来源:test_model.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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