当前位置: 首页>>代码示例>>PHP>>正文


PHP basename函数代码示例

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


在下文中一共展示了basename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $_SERVER['REDIRECT_STATUS'] = "200";
     $_SERVER['HTTP_HOST'] = "slim";
     $_SERVER['HTTP_CONNECTION'] = "keep-alive";
     $_SERVER['HTTP_CACHE_CONTROL'] = "max-age=0";
     $_SERVER['HTTP_ACCEPT'] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3";
     $_SERVER['HTTP_ACCEPT_ENCODING'] = "gzip,deflate,sdch";
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en-US,en;q=0.8";
     $_SERVER['HTTP_ACCEPT_CHARSET'] = "ISO-8859-1,utf-8;q=0.7,*;q=0.3";
     $_SERVER['PATH'] = "/usr/bin:/bin:/usr/sbin:/sbin";
     $_SERVER['SERVER_SIGNATURE'] = "";
     $_SERVER['SERVER_SOFTWARE'] = "Apache";
     $_SERVER['SERVER_NAME'] = "slim";
     $_SERVER['SERVER_ADDR'] = "127.0.0.1";
     $_SERVER['SERVER_PORT'] = "80";
     $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
     $_SERVER['DOCUMENT_ROOT'] = rtrim(dirname(__FILE__), '/');
     $_SERVER['SERVER_ADMIN'] = "you@example.com";
     $_SERVER['SCRIPT_FILENAME'] = __FILE__;
     $_SERVER['REMOTE_PORT'] = "55426";
     $_SERVER['REDIRECT_URL'] = "/";
     $_SERVER['GATEWAY_INTERFACE'] = "CGI/1.1";
     $_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
     $_SERVER['REQUEST_METHOD'] = "GET";
     $_SERVER['QUERY_STRING'] = "";
     $_SERVER['REQUEST_URI'] = "/";
     $_SERVER['SCRIPT_NAME'] = basename(__FILE__);
     $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
     $_SERVER['REQUEST_TIME'] = "1285647051";
     $_SERVER['argv'] = array();
     $_SERVER['argc'] = 0;
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:34,代码来源:ResponseTest.php

示例2: generatePDF

 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:28,代码来源:ShopInvoice.php

示例3: writeMsg

/** 
 * Write a information message 
 * 
 * @param $msg Message to write to console.
 * @access public
 */
function writeMsg($msg)
{
    global $VERBOSE;
    if ($VERBOSE) {
        echo basename(__FILE__) . ": [INFO] " . $msg . "\n";
    }
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:13,代码来源:instrument.php

示例4: mytheme_add_admin

function mytheme_add_admin()
{
    global $themename, $shortname, $options;
    if ($_GET['page'] == basename(__FILE__)) {
        if ('save' == $_REQUEST['action']) {
            foreach ($options as $value) {
                if ($value['type'] != 'header') {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                }
            }
            foreach ($options as $value) {
                if (isset($_REQUEST[$value['id']])) {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                } else {
                    delete_option($value['id']);
                }
            }
            header("Location: themes.php?page=settings.php&saved=true");
            die;
        } else {
            if ('reset' == $_REQUEST['action']) {
                foreach ($options as $value) {
                    delete_option($value['id']);
                }
                header("Location: themes.php?page=settings.php&reset=true");
                die;
            }
        }
    }
    add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
开发者ID:erka,项目名称:wp-blog,代码行数:31,代码来源:settings.php

示例5: template

 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:38,代码来源:Compiler.php

示例6: findShortestPath

 /**
  * Returns the shortest path from $from to $to
  *
  * @param  string $from
  * @param  string $to
  * @param  bool   $directories if true, the source/target are considered to be directories
  * @return string
  */
 public function findShortestPath($from, $to, $directories = false)
 {
     if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
         throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
     }
     $from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
     $to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
     if ($directories) {
         $from .= '/dummy_file';
     }
     if (dirname($from) === dirname($to)) {
         return './' . basename($to);
     }
     $commonPath = $to;
     while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
         $commonPath = strtr(dirname($commonPath), '\\', '/');
     }
     if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
         return $to;
     }
     $commonPath = rtrim($commonPath, '/') . '/';
     $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/');
     $commonPathCode = str_repeat('../', $sourcePathDepth);
     return $commonPathCode . substr($to, strlen($commonPath)) ?: './';
 }
开发者ID:r15ch13,项目名称:composer,代码行数:33,代码来源:Filesystem.php

示例7: load

 function load()
 {
     $this->values = array();
     if (JRequest::getCmd('from_display', false) == false) {
         $this->values[] = JHTML::_('select.option', '', JText::_('HIKA_INHERIT'));
     }
     $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     foreach ($this->default as $d) {
         $this->values[] = JHTML::_('select.option', $d, JText::_(strtoupper($d)));
     }
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     }
     $closeOpt = '';
     $values = $this->getLayout();
     foreach ($values as $value) {
         if (substr($value, 0, 1) == '#') {
             if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
                 $this->values[] = JHTML::_('select.optgroup', $closeOpt);
             }
             $value = substr($value, 1);
             $closeOpt = '-- ' . JText::sprintf('FROM_TEMPLATE', basename($value)) . ' --';
             $this->values[] = JHTML::_('select.optgroup', $closeOpt);
         } else {
             $this->values[] = JHTML::_('select.option', $value, $value);
         }
     }
     if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
         $this->values[] = JHTML::_('select.optgroup', $closeOpt);
     }
 }
开发者ID:q0821,项目名称:esportshop,代码行数:31,代码来源:quantitydisplay.php

示例8: elgg_register_classes

/**
 * Register all files found in $dir as classes
 * Need to be named MyClass.php
 *
 * @param string $dir The dir to look in
 *
 * @return void
 * @since 1.8.0
 */
function elgg_register_classes($dir)
{
    $classes = elgg_get_file_list($dir, array(), array(), array('.php'));
    foreach ($classes as $class) {
        elgg_register_class(basename($class, '.php'), $class);
    }
}
开发者ID:nhunaro,项目名称:Elgg,代码行数:16,代码来源:elgglib.php

示例9: renderAudioPlayer

 /**
  * Renders audio player for the blog
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function renderAudioPlayer($uri, $options = array())
 {
     // Merge the options with the default options
     $options = array_replace_recursive(self::$defaultAudioOptions, $options);
     // Generate a random uid
     $uniqid = uniqid();
     $uid = 'audio-' . EBMM::getHash($uri . $uniqid);
     // Url to the audio
     $url = $this->normalizeURI($uri);
     // Get the track if there is no track provided
     if (!$options['track']) {
         $options['track'] = basename($url);
     }
     // Set a default artist if artist isn't set
     if (!$options['artist']) {
         $options['artist'] = JText::_('COM_EASYBLOG_BLOCKS_AUDIO_ARTIST');
     }
     $template = EB::template();
     $template->set('uid', $uid);
     $template->set('showTrack', $options['showTrack']);
     $template->set('showDownload', $options['showDownload']);
     $template->set('showArtist', $options['showArtist']);
     $template->set('autoplay', $options['autoplay']);
     $template->set('loop', $options['loop']);
     $template->set('artist', $options['artist']);
     $template->set('track', $options['track']);
     $template->set('url', $url);
     $output = $template->output('site/blogs/blocks/audio');
     return $output;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:38,代码来源:media.php

示例10: init_paths

 /**
  * Парсит пути
  */
 private function init_paths()
 {
     $filter = new filter();
     $this->dir = substr($filter->server('PHP_SELF'), 0, 0 - strlen(basename($filter->server('PHP_SELF'))));
     $this->root = $this->dir;
     $this->link = substr($filter->server('REQUEST_URI'), strlen($this->dir));
 }
开发者ID:TwinkleFox,项目名称:TwinkleFox_CMF,代码行数:10,代码来源:url.php

示例11: getShortName

 /**
  * Return book's short name
  *
  * @return string
  */
 public function getShortName()
 {
     if ($this->short_name === null) {
         $this->short_name = str_replace('_', '-', basename($this->path));
     }
     return $this->short_name;
 }
开发者ID:activecollab,项目名称:shade,代码行数:12,代码来源:Element.php

示例12: onParseContentBlock

 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = NULL;
     if ($name == "fotorama" && $shortcut) {
         list($pattern, $style, $nav, $autoplay) = $this->yellow->toolbox->getTextArgs($text);
         if (empty($style)) {
             $style = $this->yellow->config->get("fotoramaStyle");
         }
         if (empty($nav)) {
             $nav = $this->yellow->config->get("fotoramaNav");
         }
         if (empty($autoplay)) {
             $autoplay = $this->yellow->config->get("fotoramaAutoplay");
         }
         if (empty($pattern)) {
             $files = $page->getFiles(true);
         } else {
             $images = $this->yellow->config->get("imageDir");
             $files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
         }
         if (count($files)) {
             $page->setLastModified($files->getModified());
             $output = "<div class=\"" . htmlspecialchars($style) . "\" data-nav=\"" . htmlspecialchars($nav) . "\" data-autoplay=\"" . htmlspecialchars($autoplay) . "\" data-loop=\"true\">\n";
             foreach ($files as $file) {
                 list($width, $height) = $this->yellow->toolbox->detectImageInfo($file->fileName);
                 $output .= "<img src=\"" . htmlspecialchars($file->getLocation()) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation()) . "\" title=\"" . basename($file->getLocation()) . "\" />\n";
             }
             $output .= "</div>";
         } else {
             $page->error(500, "Fotorama '{$pattern}' does not exist!");
         }
     }
     return $output;
 }
开发者ID:rainkarnichi,项目名称:yellow-extensions,代码行数:34,代码来源:fotorama.php

示例13: clearCache

 public static function clearCache()
 {
     if (!is_dir(CACHE_PATH)) {
         return;
     }
     try {
         $dirIterator = new RecursiveDirectoryIterator(CACHE_PATH);
         $iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($iterator as $path) {
             switch (true) {
                 case '.' == basename($path->__toString()):
                 case '..' == basename($path->__toString()):
                 case '...' == basename($path->__toString()):
                     break;
                 case $path->isDir():
                     rmdir($path->__toString());
                     break;
                 default:
                     unlink($path->__toString());
                     break;
             }
         }
         rmdir(CACHE_PATH);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:HuyTran0424,项目名称:noeavrsev345452dfgdfgsg,代码行数:27,代码来源:App.php

示例14: upload

 function upload($source, $target)
 {
     if ($this->error()) {
         return 0;
     }
     $old_dir = $this->ftp_pwd();
     $dirname = dirname($target);
     $filename = basename($target);
     if (!$this->ftp_chdir($dirname)) {
         if ($this->ftp_mkdir($dirname)) {
             $this->ftp_chmod($dirname);
             if (!$this->ftp_chdir($dirname)) {
                 $this->set_error(FTP_ERR_CHDIR);
             }
             $this->ftp_put('index.htm', getglobal('setting/attachdir') . '/index.htm', FTP_BINARY);
         } else {
             $this->set_error(FTP_ERR_MKDIR);
         }
     }
     $res = 0;
     if (!$this->error()) {
         if ($fp = @fopen($source, 'rb')) {
             $res = $this->ftp_fput($filename, $fp, FTP_BINARY);
             @fclose($fp);
             !$res && $this->set_error(FTP_ERR_TARGET_WRITE);
         } else {
             $this->set_error(FTP_ERR_SOURCE_READ);
         }
     }
     $this->ftp_chdir($old_dir);
     return $res ? 1 : 0;
 }
开发者ID:softhui,项目名称:discuz,代码行数:32,代码来源:discuz_ftp.php

示例15: importTranslations

 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
开发者ID:txandy,项目名称:laravel-translation-manager,代码行数:33,代码来源:Manager.php


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