本文整理汇总了PHP中file_path函数的典型用法代码示例。如果您正苦于以下问题:PHP file_path函数的具体用法?PHP file_path怎么用?PHP file_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClassInstance
/**
* Метод получает экземпляр класса и, если нужно, кеширует его.
*/
public static function getClassInstance($__DIR__, $subDir, $className, $parent, $caching = true)
{
if (!is_valid_file_name($className)) {
return null;
//---
}
$className = get_file_name($className);
if ($className == $parent) {
//Абстрактный класс/интерфейс лежит рядом с классами реализации - пропустим его
return null;
}
//Абсолютный путь к классу
$classPath = file_path(array($__DIR__, $subDir), $className, PsConst::EXT_PHP);
//Ключ кеширования
$cacheKey = md5($classPath);
$CACHE = $caching ? SimpleDataCache::inst(__CLASS__, __FUNCTION__) : null;
if ($CACHE && $CACHE->has($cacheKey)) {
return $CACHE->get($cacheKey);
}
$INST = null;
if (is_file($classPath)) {
//Подключим данный класс
require_once $classPath;
//Проверим, существует ли класс
$rc = PsUtil::newReflectionClass($className, false);
$INST = $rc && $rc->isSubclassOf($parent) ? $rc->newInstance() : null;
}
if ($CACHE && $INST) {
$CACHE->set($cacheKey, $INST);
}
return $INST;
}
示例2: init
/**
* Метод вызывается для инициализации окружения:
* 1. Директория ресурсов окружения будет подключена в Autoload
* 2. Файл, включающий окружение, будет выполнен
*/
public static function init()
{
if (self::$inited) {
return;
//---
}
self::$inited = true;
//---
/*
* Проверим, нужно ли подключать окружение
*/
if (self::isSkipInclude()) {
return;
//---
}
$env = self::env();
if (!$env) {
return;
//---
}
$envDir = array_get_value($env, ConfigIni::environments());
if (!$envDir) {
return PsUtil::raise('Environment [{}] not found', $env);
}
if (!is_dir($envDir)) {
return PsUtil::raise('Environment dir for [{}] not found', $env);
}
$envSrcDir = next_level_dir($envDir, DirManager::DIR_SRC);
$envIncFile = file_path($envDir, $env, PsConst::EXT_PHP);
if (!is_file($envIncFile)) {
return PsUtil::raise('Environment include file for [{}] not found', $env);
}
$LOGGER = PsLogger::inst(__CLASS__);
if ($LOGGER->isEnabled()) {
$LOGGER->info('Including \'{}\' environment for context \'{}\'', $env, PsContext::describe());
$LOGGER->info('Env dir: {}', $envDir);
$LOGGER->info('Src dir: {}', $envSrcDir);
$LOGGER->info('Inc file: {}', $envIncFile);
}
//Проинициализировано окружение
self::$included = true;
//Регистрируем директорию с классами, специфичными только для данного окружения
Autoload::inst()->registerBaseDir($envSrcDir, false);
//Выполним необходимое действие
$PROFILER = PsProfiler::inst(__CLASS__);
try {
$LOGGER->info('{');
$PROFILER->start($env);
self::initImpl($LOGGER, $envIncFile);
$secundomer = $PROFILER->stop();
$LOGGER->info('}');
$LOGGER->info('Inc file included for {} sec', $secundomer->getTime());
} catch (Exception $ex) {
$PROFILER->stop(false);
$LOGGER->info('Inc file execution error: [{}]', $ex->getMessage());
throw $ex;
//---
}
}
示例3: partial
/**
* Base helper, accessible in controllers, views and models
*
* @filesource
* @copyright Copyright (c) 2008-2014, Kamil "Brego" Dzieliński
* @license http://opensource.org/licenses/mit-license.php The MIT License
* @author Kamil "Brego" Dzieliński <brego@brego.dk>
* @link http://prank.brego.dk/ Prank's project page
* @package Prank
* @subpackage Helpers
* @since Prank 0.25
* @version Prank 0.75
*/
function partial($name, $params = [])
{
$registry = Registry::instance();
$controller = $registry->current_controller;
extract($params);
extract($controller->view_variables);
require file_path($registry->config->views, $controller->get_controller(), '_' . $name . '.php');
}
示例4: configure
function configure()
{
option('app_dir', file_path(dirname(option('root_dir')), 'app'));
option('lib_dir', file_path(option('app_dir'), 'lib'));
option('views_dir', file_path(option('app_dir'), 'views'));
option('session', "app_session");
option('debug', false);
setlocale(LC_TIME, "ro_RO");
}
示例5: dimpConsoleLog
function dimpConsoleLog()
{
global $CALLED_FILE;
if ($CALLED_FILE) {
$log = file_path(dirname($CALLED_FILE), get_file_name($CALLED_FILE), 'log');
$FULL_LOG = PsLogger::controller()->getFullLog();
$FULL_LOG = mb_convert_encoding($FULL_LOG, 'UTF-8', 'cp866');
file_put_contents($log, $FULL_LOG);
}
}
示例6: test_file_path
function test_file_path()
{
$p = "/one/two/three";
assert_equal(file_path('/one', 'two', 'three'), $p);
assert_equal(file_path('/one', '/two', 'three'), $p);
assert_equal(file_path('/one', 'two', '///three'), $p);
assert_equal(file_path('/one', 'two', 'three/'), $p . '/');
assert_equal(file_path('/one', 'two', 'three//'), $p . '/');
assert_equal(file_path('/one', '\\two', '\\three//'), $p . '/');
}
示例7: getHtml
/**
* Метод форматирует вывод Exception в html
*/
public static function getHtml(Exception $exception)
{
//Вычитываем [exception.html] и производим замены
try {
return str_replace('{STACK}', ExceptionHelper::formatStackHtml($exception), file_get_contents(file_path(__DIR__, 'exception.html')));
} catch (Exception $ex) {
//Если в методе форматирования эксепшена ошибка - прекращаем выполнение.
die("Exception [{$exception->getMessage()}] stack format error: [{$ex->getMessage()}]");
}
}
示例8: before_render
function before_render($content_or_func, $layout, $locals, $view_path)
{
if (is_callable($content_or_func)) {
} elseif (file_exists($view_path) && !array_key_exists('content', $locals)) {
// a view file but not a layout
$view_path = file_path(option('views_dir'), basename($content_or_func, ".html.php") . "_filtered.html.php");
} else {
# it's a string
$content_or_func .= "∞FILTERED∞";
}
return array($content_or_func, $layout, $locals, $view_path);
}
示例9: render_filter_rewrite_short_tags
/**
* a filter for rewriting views without short_open_tags
*
* @param string $view_path
* @return string $path to converted view file
*/
function render_filter_rewrite_short_tags($view_path)
{
if (option('rewrite_short_tags') == true && (bool) @ini_get('short_open_tag') === false) {
# cache path, maybe in tmp/cache/rsot_views/
$cache_path = file_path(option('rewrite_sot_cache_dir'), $view_path);
if (!file_exists($cache_path) || filemtime($cache_path) != filemtime($view_path)) {
$view = file_get_contents($view_path);
$transformed_view = preg_replace("/;*\\s*\\?>/", "; ?>", str_replace('<?=', '<?php echo ', $view));
# TODO: store it in cache
# …
}
$view_path = $cache_path;
}
return $view_path;
}
示例10: inst
/** @return DirItem */
public static function inst($path, $name = null, $ext = null)
{
$absPath = normalize_path(file_path($path, $name, $ext));
if (!$absPath || DIR_SEPARATOR == $absPath || PATH_BASE_DIR == $absPath || PATH_BASE_DIR == $absPath . DIR_SEPARATOR) {
$absPath = PATH_BASE_DIR;
} else {
if (!starts_with($absPath, PATH_BASE_DIR)) {
$absPath = next_level_dir(PATH_BASE_DIR, $absPath);
}
}
if (array_key_exists($absPath, self::$items)) {
return self::$items[$absPath];
}
$relPath = cut_string_start($absPath, PATH_BASE_DIR);
$relPath = ensure_dir_startswith_dir_separator($relPath);
return self::$items[$absPath] = new DirItem($relPath, $absPath);
}
示例11: inst
/** @return DirItem */
public static function inst($path, $name = null, $ext = null)
{
$itemPath = normalize_path(file_path($path, $name, $ext));
$corePath = normalize_path(PATH_BASE_DIR);
//Обезопасим пути, в которых есть русские буквы
try {
$itemPath = iconv('UTF-8', 'cp1251', $itemPath);
} catch (Exception $e) {
//Если произойдёт ошибка - игнорируем
}
$isAbs = starts_with($itemPath, $corePath);
$absPath = $isAbs ? $itemPath : next_level_dir($corePath, $itemPath);
if (array_key_exists($absPath, self::$items)) {
return self::$items[$absPath];
}
$relPath = cut_string_start($absPath, $corePath);
$relPath = ensure_starts_with($relPath, DIR_SEPARATOR);
return self::$items[$absPath] = new DirItem($relPath, $absPath);
}
示例12: index
function index($id = null)
{
$data = $this->parent_account_model->getIdenticalColumn();
debug($this->parent_account_model->db->last_query());
if ($id == null) {
$this->_set_flashdata('Invalid Feed reference key', 'error');
redirect('home');
}
$id = trim($id);
$activity_feed = $this->parent_account_model->getActivityFeedById($id);
if (empty($activity_feed)) {
$this->_set_flashdata('No activity feed found with the specified key', 'error');
redirect('home');
}
$keywords = array();
foreach (explode(' ', $activity_feed->description) as $keyword) {
if (strlen($keyword) > 3) {
$keywords[] = $keyword;
}
}
$fb_app_id = $this->session->userdata('facebook_app_id');
/*
* OpenGraph Meta Settings
*/
$this->data['title'] = $activity_feed->from . ' ' . $activity_feed->title;
$this->data['description'] = $activity_feed->description;
$this->data['keywords'] = implode(', ', $keywords);
$this->data['author'] = 'Seedplane Development Team';
$this->data['copyright'] = 'Seedplane';
$this->data['app_name'] = 'seedplane';
$this->data['social_type'] = 'article';
$this->data['image'] = isset($activity_feed->image) && $activity_feed->image ? file_path('', $activity_feed->image, 'user_missing.png', 'uploads/default/') : '';
$this->data['fb_app_id'] = isset($fb_app_id) && $fb_app_id ? $fb_app_id : '819064394807097';
// end meta settings
$this->data['activity_feed'] = $activity_feed;
$this->ims_template->build('view_feed', $this->data);
}
示例13: absFilePath
public final function absFilePath($dirs, $fileName, $ext = null)
{
return file_path($this->absDirPath($dirs), $fileName, $ext);
}
示例14: dolog
<?php
require_once '../ToolsResources.php';
$CALLED_FILE = __FILE__;
dolog(__FILE__ . ' called in ' . time());
file_append_contents(file_path(__DIR__, 'called.log'), time() . "\n");
示例15: lang
echo $activity_feed->activity_feed_id;
?>
"><?php
echo lang('share');
?>
</a></div>
<div class="innerWrapper">
<input name="public_url" type="hidden" value="<?php
echo site_url('view_feed/index/' . $activity_feed->activity_feed_id);
?>
" />
<?php
if ($activity_feed->image != '') {
?>
<div class="activity_image_div"><img src="<?php
echo file_path("", $activity_feed->image, 'NoImageAvailable.jpg', 'uploads/default/');
?>
"/></div>
<?php
}
?>
<div class="innerContent fli">
<h3><?php
echo '<span class="activity_from">' . $activity_feed->from . '</span>' . ' ' . $activity_feed->title;
?>
</h3>
<span class="timeLog"><?php
echo time_elapsed_string($activity_feed->date_time);
?>
</span>
<?php