本文整理汇总了PHP中str_finish函数的典型用法代码示例。如果您正苦于以下问题:PHP str_finish函数的具体用法?PHP str_finish怎么用?PHP str_finish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_finish函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: mount
/**
* Bind controller methods into a path
*
* @param string $path
* @param string $controller_klass
*
* @example
*
* class MyController {
* // Mount callback
* public static function mounted($path) {
* var_dump("Successfully mounted at " . $path);
* }
*
* // GET /path
* function getIndex() {}
*
* // POST /path/create
* function postCreate() {}
*
* // PUT /path/update
* function putUpdate() {}
*
* // DELETE /path
* function deleteIndex() {}
* }
* Hook\Http\Router::mount('/', 'MyController');
*
*/
public static function mount($path, $controller_klass)
{
$mounted = null;
$methods = get_class_methods($controller_klass);
// skip
if (!$methods) {
debug("'{$controller_klass}' has no methods.");
return;
}
foreach ($methods as $method_name) {
// skip invalid methods
if ($method_name == '__construct') {
continue;
}
// call 'mounted' method
if ($method_name == 'mounted') {
$mounted = call_user_func(array($controller_klass, 'mounted'), $path);
continue;
}
preg_match_all('/^(get|put|post|patch|delete)(.*)/', $method_name, $matches);
$has_matches = count($matches[1]) > 0;
$http_method = $has_matches ? $matches[1][0] : 'any';
$route_name = $has_matches ? $matches[2][0] : $method_name;
$route = str_finish($path, '/');
if ($route_name !== 'index') {
$route .= snake_case($route_name);
}
static::$instance->{$http_method}($route, "{$controller_klass}:{$method_name}");
}
return $mounted;
}
开发者ID:CFLOVEYR,项目名称:hook,代码行数:60,代码来源:Router.php
示例2: _initConfig
private function _initConfig()
{
$basePath = str_finish(dirname(__FILE__), '/');
$configPath = $basePath . '../../../config';
$loader = new FileLoader(new Filesystem(), $configPath);
$this->config = new Repository($loader, $this->environment);
}
开发者ID:kps3,项目名称:wordpress-base,代码行数:7,代码来源:BaseTheme.php
示例3: env
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
* @param string $key
* @param mixed $default
* @return mixed
*/
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return value($default);
}
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
if (strlen($value) > 1 && starts_with($value, '"') && str_finish($value, '"')) {
return substr($value, 1, -1);
}
return $value;
}
开发者ID:visavi,项目名称:rotorcms,代码行数:31,代码来源:helpers.php
示例4: publish
/**
* Publishes all themes files in the given package to their
* respective themes.
*
* @param string $source
* @return bool
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function publish($source)
{
if (!$this->filesystem->isDirectory($source)) {
throw new InvalidArgumentException("Source [{$source}] does not exist.");
}
$paths = $this->getThemeSourcePaths($source);
foreach ($paths as $path) {
$relativePath = str_replace(str_finish($source, '/'), '', $path);
$slugs = $this->extractSlugsFromPath($relativePath);
// If we cannot resolve a theme, the user has probably got assets
// for a theme which isn't in this installation. Let's not punish
// them for supporting more than the installed themes, we'll just
// let them know we've skipped it.
try {
$theme = $this->getThemeForSlugs($slugs);
} catch (RuntimeException $e) {
$this->note(sprintf('Couln\'t load theme for slug(s) [%s] in source [%s], skipping.', implode(', ', $slugs), $source));
continue;
}
$mappings = $this->getCopyMappings($path, $theme);
foreach ($mappings as $_source => $destination) {
$success = $this->filesystem->copyDirectory($_source, $destination);
if (!$success) {
throw new RuntimeException("Failed to publish [{$_source}] to [{$destination}].");
}
}
}
return true;
}
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:38,代码来源:ThemePublisher.php
示例5: registerSlackMethod
public function registerSlackMethod($name)
{
$contract = str_finish($this->contractsNamespace, "\\") . "Slack{$name}";
$shortcut = $this->shortcutPrefix . snake_case($name);
$class = str_finish($this->methodsNamespace, "\\") . $name;
$this->registerSlackSingletons($contract, $class, $shortcut);
}
开发者ID:barooney,项目名称:laravel-slack-api,代码行数:7,代码来源:SlackApiServiceProvider.php
示例6: adjustPath
public static function adjustPath($path)
{
if (!isset($path) || $path == '') {
return "";
}
return str_finish(str_replace('\\', '/', $path), '/');
}
开发者ID:padosoft,项目名称:workbench,代码行数:7,代码来源:Dir.php
示例7: buildSiteMap
/**
* Build the Site Map
*/
protected function buildSiteMap()
{
$postsInfo = $this->getPostsInfo();
$dates = array_values($postsInfo);
sort($dates);
$lastmod = last($dates);
// $url = trim(url(), '/') . '/';
$url = str_finish(url(), '/');
$xml = [];
$xml[] = '<?xml version="1.0" encoding="UTF-8"?' . '>';
$xml[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$xml[] = ' <url>';
$xml[] = " <loc>{$url}</loc>";
$xml[] = " <lastmod>{$lastmod}</lastmod>";
$xml[] = ' <changefreq>daily</changefreq>';
$xml[] = ' <priority>0.8</priority>';
$xml[] = ' </url>';
foreach ($postsInfo as $slug => $lastmod) {
$xml[] = ' <url>';
$xml[] = " <loc>{$url}blog/{$slug}</loc>";
$xml[] = " <lastmod>{$lastmod}</lastmod>";
$xml[] = " </url>";
}
$xml[] = '</urlset>';
return join("\n", $xml);
}
开发者ID:Armen2004,项目名称:laravel_blog,代码行数:29,代码来源:SiteMap.php
示例8: resetIndexes
/**
* @return \Illuminate\Support\Collection
*/
private function resetIndexes()
{
$storagePath = str_finish(realpath(storage_path()), DIRECTORY_SEPARATOR) . '*.index';
return collect(\File::glob($storagePath))->each(function ($index) {
unlink($index);
});
}
开发者ID:talv86,项目名称:easel,代码行数:10,代码来源:TestCase.php
示例9: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $mcid
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $mcid_id)
{
$this->validate($request, ['file' => 'required']);
$mcid = MCID::findOrFail($mcid_id);
$file = $_FILES['file'];
$fileName = md5($mcid_id . $file['name'] . time());
$path = str_finish($this->skin_path, '/') . $fileName;
$content = File::get($file['tmp_name']);
if (is_image($file['type']) && $file['size'] <= 150 * 1000) {
list($img_w, $img_h) = getimagesize($file['tmp_name']);
if ($img_w > 64 || $img_h > 64) {
$error = "皮肤文件 '{$fileName}' 尺寸不正确.";
} else {
$result = $this->manager->saveFile($path, $content);
if ($result === true) {
$skin = Skin::where('mcid_id', $mcid->id)->first();
if ($skin == null) {
$skin = new Skin();
}
$skin->mcid_id = $mcid->id;
$skin->url = $path;
$skin->save();
return redirect()->back()->withSuccess("皮肤文件 '{$fileName}' 上传成功.");
} else {
$error = $result ?: "皮肤文件 '{$fileName}' 上传失败.";
}
}
} else {
$error = "皮肤文件 '{$fileName}' 格式或大小不正确.";
}
return redirect()->back()->withErrors([$error]);
}
开发者ID:AsakuraFuuko,项目名称:MineCraft-Skin,代码行数:39,代码来源:SkinController.php
示例10: view
/**
* 响应一个视图
*
* @param string $view
* @param array $data
* @param array $mergeData
*
* @return \Illuminate\View\View
*/
public function view($view = null, array $data = array(), array $mergeData = array())
{
if (!is_null($view)) {
//添加view目录前缀
$view = str_finish($this->viewPrefix, '.') . $view;
}
return view($view, $data, $mergeData);
}
开发者ID:netxinyi,项目名称:meigui,代码行数:17,代码来源:Controller.php
示例11: setupPaths
protected function setupPaths()
{
$basePath = str_finish(get_template_directory(), '/');
$controllersDirectory = $basePath . 'controllers';
$modelsDirectory = $basePath . 'models';
Illuminate\Support\ClassLoader::register();
Illuminate\Support\ClassLoader::addDirectories(array($controllersDirectory, $modelsDirectory));
}
开发者ID:stormsson,项目名称:Larapress,代码行数:8,代码来源:larapress.php
示例12: getTitleAttribute
public function getTitleAttribute()
{
$title = str_replace(array('http://', 'https://'), '', $this->url);
$title = str_replace('www.', '', $title);
$title = str_finish($title, '/');
$title = substr($title, 0, strlen($title) - 1);
return $title;
}
开发者ID:dbirchak,项目名称:ping,代码行数:8,代码来源:Check.php
示例13: __construct
/**
* Main constructor.
*
* Loads up the config and service container
*
* Utilizes 'illuminate/config' package.
*/
protected function __construct()
{
$basePath = str_finish(dirname(__DIR__), '/');
$configPath = $basePath . 'config';
$loader = new FileLoader(new Filesystem(), $configPath);
$this->config = new Repository($loader, null);
$this->container = new Container();
$this->bootstrapWebserviceContainer($this->container);
}
开发者ID:smsorange,项目名称:api-library,代码行数:16,代码来源:Main.php
示例14: compilePath
public function compilePath($name)
{
$nextpath = str_replace('/_', '/', strtolower(implode('_', array_slice(preg_split('/(?=[A-Z])/', $this->argument('name')), 1))));
if (empty($nextpath)) {
$nextpath = str_finish($this->argument('name'), '/');
}
$path = str_finish($this->path, '/') . $nextpath;
return $path;
}
开发者ID:triasbrata,项目名称:ModuleGenerator,代码行数:9,代码来源:CreateView.php
示例15: url
public static function url($src, $key = null)
{
if (static::is_url($src)) {
return $src;
}
if ($key && ($static = static::config("paths.{$key}"))) {
$src = str_finish($static, '/') . $src;
}
return esc_url(get_template_directory_uri() . '/' . $src);
}
开发者ID:solutionworks,项目名称:theme-setup,代码行数:10,代码来源:Yare.php
示例16: setConfiguration
public function setConfiguration($creds)
{
$basePath = str_finish(dirname(__FILE__), '/../../');
$defaultConfigPath = $basePath . 'config';
$defaultLoader = new FileLoader(new Filesystem(), $defaultConfigPath);
$this->config = new Repository($defaultLoader, 'production');
$this->config->set('pexconnection.username', $creds['username']);
$this->config->set('pexconnection.password', $creds['password']);
$this->creds = ['password' => $this->config->get('pexconnection.password'), 'username' => $this->config->get('pexconnection.username')];
}
开发者ID:kevin-cole,项目名称:pex-php,代码行数:10,代码来源:PexConnection.php
示例17: namespaceChecker
private function namespaceChecker($string)
{
if (!is_null($string)) {
if (Str::contains($string, '/')) {
$string = str_replace('/', '\\', $string);
}
return str_finish($string, '\\');
}
return $string;
}
开发者ID:triasbrata,项目名称:ModuleGenerator,代码行数:10,代码来源:ControllerHelper.php
示例18: getConfigurationFiles
protected function getConfigurationFiles(Application $app)
{
$configPath = str_finish($app->configPath(), '/');
$files = $this->getConfigurationFilesInPath($configPath);
foreach (explode('.', $app->environment()) as $env) {
$configPath .= $env . '/';
$files = array_merge_recursive($files, $this->getConfigurationFilesInPath($configPath));
}
return $files;
}
开发者ID:KinaMarie,项目名称:laravel-5-base-app-support,代码行数:10,代码来源:LoadConfiguration.php
示例19: findFiles
/**
* @param $path
* @param $fileName
* @return array
*/
public function findFiles($path, $fileName)
{
if ($path == '') {
$path = base_path();
}
if (File::isDirectory($path)) {
$path = str_finish($path, '/');
}
$path .= $fileName;
return File::glob($path);
}
开发者ID:b2msrl,项目名称:laravel-composer-security,代码行数:16,代码来源:FileHelper.php
示例20: adjustPath
public static function adjustPath($path)
{
if ($path == '') {
return array();
}
$p = explode(",", str_replace('\\', '/', $path));
$pathList = array_map(function ($item) {
return str_finish($item, '/');
}, $p);
return $pathList;
}
开发者ID:padosoft,项目名称:laravel-composer-security,代码行数:11,代码来源:FileHelper.php
注:本文中的str_finish函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论