本文整理汇总了PHP中str_finish函数的典型用法代码示例。如果您正苦于以下问题:PHP str_finish函数的具体用法?PHP str_finish怎么用?PHP str_finish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_finish函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例6: adjustPath
public static function adjustPath($path)
{
if (!isset($path) || $path == '') {
return "";
}
return str_finish(str_replace('\\', '/', $path), '/');
}
示例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);
}
示例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);
});
}
示例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]);
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}