• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP touch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: makeProjectDir

 protected function makeProjectDir($srcDir = null, $logsDir = null, $cloverXmlPaths = null, $logsDirUnwritable = false, $jsonPathUnwritable = false)
 {
     if ($srcDir !== null && !is_dir($srcDir)) {
         mkdir($srcDir, 0777, true);
     }
     if ($logsDir !== null && !is_dir($logsDir)) {
         mkdir($logsDir, 0777, true);
     }
     if ($cloverXmlPaths !== null) {
         if (is_array($cloverXmlPaths)) {
             foreach ($cloverXmlPaths as $cloverXmlPath) {
                 touch($cloverXmlPath);
             }
         } else {
             touch($cloverXmlPaths);
         }
     }
     if ($logsDirUnwritable) {
         if (file_exists($logsDir)) {
             chmod($logsDir, 0577);
         }
     }
     if ($jsonPathUnwritable) {
         touch($this->jsonPath);
         chmod($this->jsonPath, 0577);
     }
 }
开发者ID:Kreed1346,项目名称:BookSmart,代码行数:27,代码来源:ProjectTestCase.php


示例2: setupLanguageFile

 protected function setupLanguageFile($catalogue, $languageEntity)
 {
     $languageFile = __DIR__ . sprintf("/../Resources/translations/%s.%s.db", $catalogue, $languageEntity);
     if (!file_exists($languageFile)) {
         touch($languageFile);
     }
 }
开发者ID:kyaroslav,项目名称:RaindropTranslationBundle,代码行数:7,代码来源:TranslationExtractCommand.php


示例3: testCheckTarget_TargetIsTooFresh

 public function testCheckTarget_TargetIsTooFresh()
 {
     \touch($this->sourceFile);
     \touch($this->targetFile, time() + 10);
     $result = $this->getTplInst()->checkTarget();
     $this->assertFalse($result);
 }
开发者ID:comos,项目名称:tage,代码行数:7,代码来源:FsBasedTplTest.php


示例4: purge_step

 public function purge_step($old_state)
 {
     switch ($old_state) {
         case '':
             // Empty means nothing has run yet
             global $phpbb_root_path;
             $phpbb_store_path = $phpbb_root_path . 'store/';
             $this->del_content_dir('d120de/banner/default/');
             $this->del_content_dir('d120de/banner/event/');
             $this->del_content_dir('d120de/banner/');
             unlink($phpbb_store_path . 'd120de/index.htm');
             //this fails if there are other folders than banner
             $del_res = rmdir($phpbb_store_path . 'd120de/');
             if ($del_res === false) {
                 //we faild create index.htm again
                 touch($phpbb_store_path . 'd120de/index.htm');
             }
             return 'del_content_dir';
             break;
         default:
             // Run parent purge step method
             return parent::purge_step($old_state);
             break;
     }
 }
开发者ID:d120,项目名称:phpbb-banner,代码行数:25,代码来源:ext.php


示例5: Get

 function Get($rss_url, $rss_feed_id)
 {
     $output = '';
     if (!isset($this->num_results)) {
         $this->num_results = 5;
     }
     if (!isset($this->description)) {
         $this->description = FALSE;
     }
     $result = $this->Parse($rss_url);
     if ($result && $result['items_count'] == 0) {
         return null;
     } else {
         if ($result) {
             $output = "<ul class='rss_feed'>";
             for ($i = 0; $i < min($this->num_results, $result['items_count']); $i++) {
                 $output .= "<li><a href='" . $result['items'][$i]['link'] . "' target='_new'>" . $result['items'][$i]['title'] . "</a>";
                 if ($this->description) {
                     $output .= "<br />" . $result['items'][$i]['description'];
                 }
                 $output .= "</li>\n";
             }
             $output .= "</ul>\n";
         } elseif (file_exists($cache_file)) {
             touch($cache_file);
         } else {
             //create an empty file
             if ($f = @fopen($cache_file, 'w')) {
                 fclose($f);
             }
         }
     }
     return $output;
 }
开发者ID:genaromendezl,项目名称:ATutor,代码行数:34,代码来源:lastRSS.php


示例6: verify

 /**
  * Verifies dependencies.
  * @param  array
  * @return bool
  */
 private function verify($meta)
 {
     do {
         if (!empty($meta[self::META_DELTA])) {
             // meta[file] was added by readMetaAndLock()
             if (filemtime($meta[self::FILE]) + $meta[self::META_DELTA] < time()) {
                 break;
             }
             touch($meta[self::FILE]);
         } elseif (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < time()) {
             break;
         }
         if (!empty($meta[self::META_CALLBACKS]) && !Cache::checkCallbacks($meta[self::META_CALLBACKS])) {
             break;
         }
         if (!empty($meta[self::META_ITEMS])) {
             foreach ($meta[self::META_ITEMS] as $depFile => $time) {
                 $m = $this->readMetaAndLock($depFile, LOCK_SH);
                 if ($m[self::META_TIME] !== $time || $m && !$this->verify($m)) {
                     break 2;
                 }
             }
         }
         return TRUE;
     } while (FALSE);
     $this->delete($meta[self::FILE], $meta[self::HANDLE]);
     // meta[handle] & meta[file] was added by readMetaAndLock()
     return FALSE;
 }
开发者ID:nette,项目名称:caching,代码行数:34,代码来源:FileStorage.php


示例7: create

 /**
  * Create user cache.
  *
  * @param string $user Twitter screen name
  * @return bool If successful true
  * @throws CacheException Any errors
  */
 public function create($user)
 {
     try {
         $path = config("cache.path") . "/{$user}";
         $json_file = "{$path}/data.json";
         if (!$this->exists($user)) {
             mkdir($path);
         }
         if (!file_exists($json_file)) {
             touch($json_file);
         }
         $response = $this->twistOAuth->get("users/show", ["id" => $user]);
         $image_url = str_replace("_normal", "", $response->profile_image_url_https);
         $info = new SplFileInfo($image_url);
         $curl = new Curl();
         $curl->setUserAgent(SaveTweet::APP_NAME . "/" . SaveTweet::APP_VERSION . " with PHP/" . PHP_VERSION);
         $curl->download($image_url, "{$path}/icon.{$info->getExtension()}");
         $curl->close();
         $data = ["name" => $response->name, "screen_name" => $response->screen_name, "id" => $response->id_str, "icon" => config("cache.http_path") . "/{$response->id_str}/icon.{$info->getExtension()}", "org_icon" => $image_url, "update_at" => time()];
         $json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         (new SplFileObject($json_file, "w"))->fwrite($json);
         return true;
     } catch (RuntimeException $e) {
         $this->_catch($e);
     }
 }
开发者ID:Hiroto-K,项目名称:SaveTweet,代码行数:33,代码来源:Cache.php


示例8: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // If DB file doesn't exist create it
     if (!Storage::exists(database_path('SPGProfileDB.sqlite'))) {
         touch(database_path('SPGProfileDB.sqlite'));
     }
     Schema::connection($this->TargetDB)->create('pass_profiles', function (Blueprint $table) {
         $table->increments('id');
         $table->string('profile_name')->unique();
         $table->boolean('number');
         $table->char('numbers', 10);
         $table->boolean('lower');
         $table->char('lower_case', 25);
         $table->boolean('upper');
         $table->char('upper_case', 26);
         $table->boolean('symbol');
         $table->char('symbols', 21);
         $table->boolean('special');
         $table->char('specials', 11);
         $table->smallInteger('length', false, true);
         $table->smallInteger('count', false, true);
         $table->float('entropy')->nullable();
         $table->timestamps();
     });
 }
开发者ID:Dev1436,项目名称:laravel-securepassgen,代码行数:30,代码来源:2015_12_12_012546_create_pass_profiles_table.php


示例9: getStatusFileObject

 /**
  * @return \SplFileObject
  *
  * @throws \RuntimeException
  */
 protected function getStatusFileObject()
 {
     if (!is_file($this->getStatusFile())) {
         touch($this->getStatusFile());
     }
     return new \SplFileObject($this->getStatusFile(), 'r+');
 }
开发者ID:mailru,项目名称:queue-processor,代码行数:12,代码来源:FileQueue.php


示例10: cache_prune_folder

/**
 * Cleanup a single cache folder
 *
 * @param string $cache_folder  path to cache folder
 * @param int    $cache_max_age maximum age of cached items in seconds
 * @param bool   $force_prune   force cache pruning even if not due according to schedule
 */
function cache_prune_folder($cache_folder, $cache_max_age, $force_prune = false, $simulate = false, $pattern = '*')
{
    if (!preg_match('#/$#', $cache_folder)) {
        $cache_folder .= '/';
    }
    $stamp = $cache_folder . 'cache_last_purge';
    $cache_mtime = @filemtime($stamp);
    // get time the cache was last purged (once a day)
    // if cache was last purged a day or more ago
    if ($force_prune || time() - $cache_mtime > $cache_max_age / 24) {
        foreach (glob($cache_folder . $pattern, GLOB_NOSORT) as $file) {
            // avoid hidden files and directories
            if (is_file($file) & !preg_match("/^\\./", $file) && time() - filemtime($file) > $cache_max_age) {
                if ($simulate) {
                    $files[] = $file;
                } else {
                    @unlink($file);
                }
                // purge cache
            }
        }
        if ($simulate) {
            return $files;
        }
        @touch($stamp);
        // mark purge as having occurred
        return true;
    }
    return false;
}
开发者ID:huya1010,项目名称:videodb,代码行数:37,代码来源:cache.php


示例11: setUp

 /**
  * Sets the path to test files
  *
  * @return void
  */
 public function setUp()
 {
     $this->filesPath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid('zfilter'));
     mkdir($this->filesPath, 0775, true);
     $this->sourceFile = $this->filesPath . DIRECTORY_SEPARATOR . 'testfile.png';
     touch($this->sourceFile);
 }
开发者ID:webowy,项目名称:zend-filter,代码行数:12,代码来源:RenameUploadWithWatermarkTest.php


示例12: load

 public function load($filename, $return_data = false)
 {
     extract(parent::load($filename));
     $this->clear_sizes();
     if (empty($this->image_temp)) {
         do {
             $this->image_temp = $this->config['temp_dir'] . substr($this->config['temp_append'] . md5(time() * microtime()), 0, 32) . '.png';
         } while (file_exists($this->image_temp));
     } else {
         if (file_exists($this->image_temp)) {
             $this->debug('Removing previous temporary image.');
             unlink($this->image_temp);
         }
     }
     $this->debug('Temp file: ' . $this->image_temp);
     if (!file_exists($this->config['temp_dir']) || !is_dir($this->config['temp_dir'])) {
         throw new \Fuel_Exception("The temp directory that was given does not exist.");
     } else {
         if (!touch($this->config['temp_dir'] . $this->config['temp_append'] . '_touch')) {
             throw new \Fuel_Exception("Could not write in the temp directory.");
         }
     }
     $this->exec('convert', '"' . $image_fullpath . '"[0] "' . $this->image_temp . '"');
     return $this;
 }
开发者ID:nathanharper,项目名称:divine-economy,代码行数:25,代码来源:imagemagick.php


示例13: createFile

 private static function createFile($file)
 {
     if (!file_exists($file)) {
         @touch($file);
         @chmod($file, DEFAULT_PERMISSION);
     }
 }
开发者ID:kavmors,项目名称:Wlight,代码行数:7,代码来源:Deployer.class.php


示例14: __construct

 public final function __construct($method)
 {
     $this->{$method}();
     if ($method == 'install') {
         touch(dirname(__FILE__) . '/installed');
     }
 }
开发者ID:steview,项目名称:moojon,代码行数:7,代码来源:moojon.base.installer.class.php


示例15: makeFile

 /**
  * Create the file if it does not exist.
  *
  * @param string $fileName
  */
 protected function makeFile($fileName)
 {
     if (file_exists($fileName)) {
         return;
     }
     touch($fileName);
 }
开发者ID:fojuth,项目名称:readmegen,代码行数:12,代码来源:Writer.php


示例16: flush

 /**
  * Sendout mail queue using the given real mailer
  * @param CakeEmail $realMailer
  */
 public function flush($realMailer)
 {
     $lockfile = $this->_config['queueFolder'] . DS . 'flush.lock';
     touch($lockfile);
     $lock = fopen($lockfile, 'r');
     if (!flock($lock, LOCK_EX)) {
         fclose($lock);
         throw new Exception('Could not get a lock for ' . $lockfile);
     }
     $processed = array();
     while ($queueFile = $this->getNext()) {
         if (array_key_exists($queueFile, $processed)) {
             throw new LogicException(sprintf('Trying to process queue file "%s" more than once.', $queueFile));
         }
         $processed[$queueFile] = true;
         $delFile = false;
         $fh = fopen($queueFile, 'r');
         if (flock($fh, LOCK_EX)) {
             $serialized = fread($fh, filesize($queueFile));
             $cakeMail = unserialize($serialized);
             $delFile = $this->tryRealSend($realMailer, $cakeMail);
             if ($delFile === false) {
                 $this->tryRequeue($queueFile);
             }
             flock($fh, LOCK_UN);
         }
         fclose($fh);
         if ($delFile === true) {
             unlink($queueFile);
         }
     }
     flock($lock, LOCK_UN);
     fclose($lock);
 }
开发者ID:hakito,项目名称:cakephp-mailqueue-plugin,代码行数:38,代码来源:QueueTransport.php


示例17: __construct

 public function __construct($directory, $suffix, $filename = 'api')
 {
     $this->queue = array();
     $this->file_location = $directory . '/' . $filename . '.' . $suffix;
     touch($this->file_location);
     $this->file = fopen($this->file_location, 'r');
 }
开发者ID:Nerutiz,项目名称:trades,代码行数:7,代码来源:Serializer.php


示例18: save

 function save($file)
 {
     if (!file_exists($file) && !touch($file)) {
         throw new Exception(sprintf('File %s does NOT exist!', $file));
     } elseif (!is_writable($file)) {
         throw new Exception(sprintf('Cannot write to %s - CHMOD it 766!', $file));
     }
     $xml = new SimpleXMLElement('<rss version="2.0" xml:base="' . $this->base . '"></rss>');
     $rss = $xml->addChild('channel');
     $rss->title = $this->title;
     $rss->link = $this->link;
     $rss->description = $this->desc;
     foreach ($this->data as $x) {
         $item = $rss->addChild('item');
         $item->title = $x['title'];
         $item->description = $x['text'];
         $item->link = $x['url'];
         #Optional tags
         if (isset($x['author'])) {
             $item->author = $x['author'];
         }
         if (isset($x['category'])) {
             $item->category = $x['cat'];
         }
         if (isset($x['date'])) {
             $item->pubDate = $x['date'];
         }
         if (isset($x['id'])) {
             $item->id = $x['ID'];
             $item->id['isPermaLink'] = 'false';
         }
     }
     #Save file
     return $xml->asXML($file);
 }
开发者ID:BGCX067,项目名称:f3site-svn-to-git,代码行数:35,代码来源:rss.php


示例19: testConstructWhenFileExists

 public function testConstructWhenFileExists()
 {
     mkdir($this->tmpDir, 0777, true);
     touch($this->tmpFile);
     $this->assertFileExists($this->tmpFile);
     new UserStateSerializer($this->tmpFile);
 }
开发者ID:jacmoe,项目名称:php-workshop,代码行数:7,代码来源:UserStateSerializerTest.php


示例20: testWatchDelAll

 function testWatchDelAll()
 {
     $dir = PhutilDirectoryFixture::newEmptyFixture();
     $root = realpath($dir->getPath());
     $files = array('a', 'b', 'c', 'd', 'e');
     $dirs = array_map(function ($file) use($root) {
         return "{$root}/{$file}";
     }, $files);
     foreach ($dirs as $d) {
         mkdir($d);
         foreach ($files as $f) {
             touch("{$d}/{$f}");
         }
         $this->watch($d);
         $this->assertFileList($d, $files);
     }
     $resp = $this->watchmanCommand('watch-list');
     $watched = $resp['roots'];
     sort($watched);
     $this->assertEqual($dirs, $watched);
     $resp = $this->watchmanCommand('watch-del-all');
     $watched = $resp['roots'];
     sort($watched);
     $this->assertEqual($dirs, $watched);
     $resp = $this->watchmanCommand('watch-list');
     $this->assertEqual(0, count($resp['roots']));
 }
开发者ID:rogerwangzy,项目名称:watchman,代码行数:27,代码来源:watch-del-all.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP touchValue函数代码示例发布时间:2022-05-23
下一篇:
PHP totranslit函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap