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


PHP dirname函数代码示例

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


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

示例1: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
开发者ID:cartalyst,项目名称:assetic-filters,代码行数:35,代码来源:LessphpFilter.php

示例2: command_dd

 function command_dd()
 {
     $args = func_get_args();
     $options = $this->get_options();
     $dd = kernel::single('dev_docbuilder_dd');
     if (empty($args)) {
         $dd->export();
     } else {
         foreach ($args as $app_id) {
             $dd->export_tables($app_id);
         }
     }
     if ($filename = $options['result-file']) {
         ob_start();
         $dd->output();
         $out = ob_get_contents();
         ob_end_clean();
         if (!is_dir(dirname($filename))) {
             throw new Exception('cannot find the ' . dirname($filename) . 'directory');
         } elseif (is_dir($filename)) {
             throw new Exception('the result-file path is a directory.');
         }
         file_put_contents($options['result-file'], $out);
         echo 'data dictionary doc export success.';
     } else {
         $dd->output();
     }
 }
开发者ID:sss201413,项目名称:ecstore,代码行数:28,代码来源:doc.php

示例3: __construct

 function __construct()
 {
     $this->_logDir = dirname(__FILE__) . "/../logs";
     if (!file_exists($this->_logDir)) {
         mkdir($this->_logDir, 0777, true);
     }
 }
开发者ID:dkraklan,项目名称:WurmUnlimitedAdmin,代码行数:7,代码来源:class.Logger.inc.php

示例4: rmFile

 protected function rmFile($file)
 {
     if (is_file($file)) {
         chmod(dirname($file), 0777);
         unlink($file);
     }
 }
开发者ID:Kreed1346,项目名称:BookSmart,代码行数:7,代码来源:ProjectTestCase.php

示例5: createPath

 protected function createPath()
 {
     $fullPath = dirname($this->fullFilePath());
     if (!is_dir($fullPath)) {
         mkdir($fullPath, 0755, true);
     }
 }
开发者ID:railsphp,项目名称:railsphp,代码行数:7,代码来源:NamedBase.php

示例6: imitateLogin

 public function imitateLogin($sdutnum, $password)
 {
     //模拟登录
     $cookie_jar = dirname(__FILE__) . "/cookie";
     $urlLogin = "http://222.206.65.12/reader/redr_verify.php";
     $post = "number={$sdutnum}&passwd={$password}&select=cert_no&returnUrl=";
     $this->curl->login_post($urlLogin, $cookie_jar, $post);
     //抓取内容
     $urlBook = "http://222.206.65.12/reader/book_lst.php";
     $html = $this->curl->get_content($urlBook, $cookie_jar);
     $loginReg = "/logout/";
     $BookReg = "/<td.*/";
     $buttonReg = "/<div\\sid=\"\\w\"><input.*\\/>/";
     $nameReg = '/height="11" \\/>.*logout/';
     $numReg = '/<p>.*<b/';
     //book number
     preg_match_all($loginReg, $html, $isLogin);
     //to judgment whether login
     preg_match_all($BookReg, $html, $bookArray);
     preg_match_all($buttonReg, $html, $buttonArray);
     preg_match_all($nameReg, $html, $nameArray);
     //username
     preg_match_all($numReg, $html, $numArray);
     empty($nameArray[0]) ? $username = null : ($username = substr($nameArray[0][0], 14, -37));
     empty($numArray[0]) ? $bookNum = null : ($bookNum = substr($numArray[0][0], 45, -25));
     $bookData['sdutnum'] = $sdutnum;
     /* after changed session*/
     $bookData['isLogin'] = $isLogin;
     $bookData['bookArray'] = $bookArray;
     $bookData['buttonArray'] = $buttonArray;
     $bookData['username'] = $username;
     $bookData['numArray'] = $numArray;
     $bookData['bookNum'] = $bookNum;
     return $bookData;
 }
开发者ID:Youthink,项目名称:Youthol-Wechat,代码行数:35,代码来源:Lib.php

示例7: import

 /**
  *
  * @param array $current_import
  * @return bool
  */
 function import(array $current_import)
 {
     // fetch the remote content
     $html = wp_remote_get($current_import['file']);
     // Something failed
     if (is_wp_error($html)) {
         $redirect_url = get_admin_url(get_current_blog_id(), '/tools.php?page=pb_import');
         error_log('\\PressBooks\\Import\\Html import error, wp_remote_get() ' . $html->get_error_message());
         $_SESSION['pb_errors'][] = $html->get_error_message();
         $this->revokeCurrentImport();
         \Pressbooks\Redirect\location($redirect_url);
     }
     $url = parse_url($current_import['file']);
     // get parent directory (with forward slash e.g. /parent)
     $path = dirname($url['path']);
     $domain = $url['scheme'] . '://' . $url['host'] . $path;
     // get id (there will be only one)
     $id = array_keys($current_import['chapters']);
     // front-matter, chapter, or back-matter
     $post_type = $this->determinePostType($id[0]);
     $chapter_parent = $this->getChapterParent();
     $body = $this->kneadandInsert($html['body'], $post_type, $chapter_parent, $domain);
     // Done
     return $this->revokeCurrentImport();
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:30,代码来源:class-pb-xhtml.php

示例8: initialize

 /**
  * {@inheritDoc}
  */
 public function initialize()
 {
     if (Filesystem::isLocalPath($this->url)) {
         $this->repoDir = $this->url;
     } else {
         $cacheDir = $this->config->get('cache-vcs-dir');
         $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
         $fs = new Filesystem();
         $fs->ensureDirectoryExists($cacheDir);
         if (!is_writable(dirname($this->repoDir))) {
             throw new \RuntimeException('Can not clone ' . $this->url . ' to access package information. The "' . $cacheDir . '" directory is not writable by the current user.');
         }
         // update the repo if it is a valid hg repository
         if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
             if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
                 $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>');
             }
         } else {
             // clean up directory and do a fresh clone into it
             $fs->removeDirectory($this->repoDir);
             if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoDir)), $output, $cacheDir)) {
                 $output = $this->process->getErrorOutput();
                 if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
                     throw new \RuntimeException('Failed to clone ' . $this->url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
                 }
                 throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output);
             }
         }
     }
     $this->getTags();
     $this->getBranches();
 }
开发者ID:composer-fork,项目名称:composer,代码行数:35,代码来源:HgDriver.php

示例9: __construct

 public function __construct($name = null, array $data = array(), $dataName = '')
 {
     $this->_className = $name;
     $this->_root = dirname(__FILE__);
     date_default_timezone_set('UTC');
     parent::__construct($name, $data, $dataName);
 }
开发者ID:hjr3,项目名称:zf2,代码行数:7,代码来源:TestCommonBackend.php

示例10: initInternal

 protected function initInternal()
 {
     parent::initInternal();
     // override default xml
     $this->ui = new AdminUI();
     $this->ui->loadFromXML(dirname(__FILE__) . '/time.xml');
 }
开发者ID:gauthierm,项目名称:pinhole,代码行数:7,代码来源:Time.php

示例11: _moduleContent

function _moduleContent(&$smarty, $module_name)
{
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $sContenidoModulo = '';
    $sAccion = getParameter('action');
    switch ($sAccion) {
        case 'new':
        case 'edit':
            $sContenidoModulo = modificarArchivo($module_name, $smarty, $local_templates_dir, $arrConf['astetcdir'], $sAccion);
            break;
        case 'list':
        default:
            $sContenidoModulo = listarArchivos($module_name, $smarty, $local_templates_dir, $arrConf['astetcdir']);
            break;
    }
    return $sContenidoModulo;
}
开发者ID:hardikk,项目名称:HNH,代码行数:25,代码来源:index.php

示例12: initialize

 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - file:        The file path or a php wrapper to log messages
  *                You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
  * - format:      The log line format (default to %time% %type% [%priority%] %message%%EOL%)
  * - time_format: The log time strftime format (default to %b %d %H:%M:%S)
  * - dir_mode:    The mode to use when creating a directory (default to 0777)
  * - file_mode:   The mode to use when creating a file (default to 0666)
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (!isset($options['file'])) {
         throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
     }
     if (isset($options['format'])) {
         $this->format = $options['format'];
     }
     if (isset($options['time_format'])) {
         $this->timeFormat = $options['time_format'];
     }
     if (isset($options['type'])) {
         $this->type = $options['type'];
     }
     $dir = dirname($options['file']);
     if (!is_dir($dir)) {
         mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
     }
     $fileExists = file_exists($options['file']);
     if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
         throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
     }
     $this->fp = fopen($options['file'], 'a');
     if (!$fileExists) {
         chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
     }
     return parent::initialize($dispatcher, $options);
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:45,代码来源:sfFileLogger.class.php

示例13: 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

示例14: test_get_item_uris

 function test_get_item_uris()
 {
     $snapshots = new Snapshots(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'documents/snapshots.rdf');
     $expected = array("http://api.talis.com/stores/schema-cache/snapshots/20071129173353.tar");
     $actual = $snapshots->get_item_uris();
     $this->assertEquals($expected, $actual);
 }
开发者ID:jhigman,项目名称:TalisRdfEditor,代码行数:7,代码来源:snapshots.test.php

示例15: preUpload

 /**
  * @ORM\PreFlush()
  */
 public function preUpload()
 {
     if ($this->file) {
         if ($this->file instanceof FileUpload) {
             $basename = $this->file->getSanitizedName();
             $basename = $this->suggestName($this->getFilePath(), $basename);
             $this->setName($basename);
         } else {
             $basename = trim(Strings::webalize($this->file->getBasename(), '.', FALSE), '.-');
             $basename = $this->suggestName(dirname($this->file->getPathname()), $basename);
             $this->setName($basename);
         }
         if ($this->_oldPath && $this->_oldPath !== $this->path) {
             @unlink($this->getFilePathBy($this->_oldProtected, $this->_oldPath));
         }
         if ($this->file instanceof FileUpload) {
             $this->file->move($this->getFilePath());
         } else {
             copy($this->file->getPathname(), $this->getFilePath());
         }
         return $this->file = NULL;
     }
     if (($this->_oldPath || $this->_oldProtected !== NULL) && ($this->_oldPath != $this->path || $this->_oldProtected != $this->protected)) {
         $oldFilePath = $this->getFilePathBy($this->_oldProtected !== NULL ? $this->_oldProtected : $this->protected, $this->_oldPath ?: $this->path);
         if (file_exists($oldFilePath)) {
             rename($oldFilePath, $this->getFilePath());
         }
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:32,代码来源:FileEntity.php


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