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


PHP String::startsWith方法代码示例

本文整理汇总了PHP中zibo\library\String::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP String::startsWith方法的具体用法?PHP String::startsWith怎么用?PHP String::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zibo\library\String的用法示例。


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

示例1: clearWidgetProperties

 /**
  * Clear the settings of this widget
  * @return null
  */
 public function clearWidgetProperties()
 {
     foreach ($this->settings as $key => $setting) {
         if (String::startsWith($key, $this->widgetSettingPrefix)) {
             unset($this->settings[$key]);
         }
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:12,代码来源:WidgetSettings.php

示例2: getAbsoluteUrl

 /**
  * Gets the absolute URL of a made reference
  * @param string $url The made reference
  * @param string $baseUrl The base URL of the node which is linking the URL
  * @param string $basePath The base path of the node which is linking the URL
  * @return string The absolute URL of the reference
  */
 protected function getAbsoluteUrl($url, $baseUrl, $basePath)
 {
     if (!String::looksLikeUrl($url)) {
         if (String::startsWith($url, '/')) {
             $url = rtrim($baseUrl, '/') . $url;
         } else {
             $url = $basePath . $url;
         }
     }
     return $url;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:18,代码来源:AbstractSpiderBite.php

示例3: makeImagesAbsolute

 /**
  * Convert the relative images to absolute ones
  * @param string $baseUrl base url for the relative images
  * @return null
  */
 public function makeImagesAbsolute($baseUrl)
 {
     $images = $this->dom->getElementsByTagName('img');
     foreach ($images as $image) {
         $src = $image->getAttribute('src');
         if (String::startsWith($src, 'http://')) {
             continue;
         }
         $image->setAttribute('src', $baseUrl . $src);
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:16,代码来源:HtmlParser.php

示例4: getRequest

 /**
  * Get the request from Joppa, if none found pass the call to the fallback router
  * @return zibo\core\Request
  */
 public function getRequest()
 {
     $query = $this->getQuery();
     if (String::startsWith($query, Zibo::DIRECTORY_WEB . Request::QUERY_SEPARATOR)) {
         return $this->router->getRequest();
     }
     $request = $this->getRequestFromQuery($query);
     if ($request) {
         return $request;
     }
     return $this->router->getRequest();
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:16,代码来源:JoppaRouter.php

示例5: biteDocument

 /**
  * Adds the URL's from the anchors in the page to the web
  * @param zibo\library\spider\Web $web The spider web
  * @param zibo\library\spider\WebNode $prey The current prey in the web
  * @param string $baseUrl Base URL of the crawl
  * @param string $preyBaseUrl Base URL of the prey
  * @param zibo\library\xml\dom\Document $dom The DOM document of the current prey
  * @return null
  */
 protected function biteDocument(Web $web, WebNode $prey, $baseUrl, $preyBaseUrl, Document $dom)
 {
     $anchors = $dom->getElementsByTagName('a');
     foreach ($anchors as $anchor) {
         $url = $anchor->getAttribute('href');
         if (!$url || String::startsWith($url, '#')) {
             continue;
         }
         if (!String::startsWith($url, 'mailto:')) {
             $url = $this->getAbsoluteUrl($url, $baseUrl, $preyBaseUrl);
         }
         $node = $web->getNode($url);
         $node->addReference($prey);
         $prey->addLink($node);
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:25,代码来源:AnchorSpiderBite.php

示例6: getDrivePrefix

 /**
  * Gets the drive prefix of a path (/, C:/)
  * @param string $path
  * @return boolean|string the drive prefix if an absolute path, false otherwise
  */
 private function getDrivePrefix($path)
 {
     if (!$path) {
         return false;
     }
     $pathLength = strlen($path);
     if ($pathLength == 1) {
         if ($path == File::DIRECTORY_SEPARATOR) {
             return File::DIRECTORY_SEPARATOR;
         }
         return false;
     }
     if ($path[0] == File::DIRECTORY_SEPARATOR) {
         if ($pathLength >= 3 && $this->isDrive($path[1]) && $path[2] == File::DIRECTORY_SEPARATOR) {
             return substr($path, 0, 3);
         }
         return File::DIRECTORY_SEPARATOR;
     }
     $drive = $path[0];
     if ($this->isDrive($drive) && String::startsWith($path, $drive . ':/')) {
         return $drive . ':/';
     }
     return false;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:29,代码来源:WindowsFileSystem.php

示例7: performCrawl

 public function performCrawl()
 {
     $socket = $this->connect();
     $this->response = $this->performHead($socket);
     $responseCode = $this->response->getResponseCode();
     if (!$responseCode) {
         throw new Exception('No response received');
     }
     if ($this->response->isRedirect()) {
         return;
     }
     $contentType = $this->response->getHeader('Content-Type');
     if ($responseCode == 200 && String::startsWith($contentType, 'text/')) {
         $this->performGet($this->response);
     }
     fclose($socket);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:17,代码来源:Crawl.php

示例8: hasPharProtocol

 /**
  * Checks if a path has been prefixed with the phar protocol (phar://)
  * @param string $path if none provided, the path of the file is assumed
  * @return boolean true if the protocol is prefixed, false otherwise
  */
 public function hasPharProtocol($path = null)
 {
     if ($path == null) {
         $path = $this->path;
     }
     return String::startsWith($path, 'phar://');
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:12,代码来源:File.php

示例9: processSource

 /**
  * Process the source, apply thumbnailer if set
  * @param string $source source to process
  * @return string source to be used by the html of this image tag
  * @throws zibo\ZiboException when the source file could not be found
  */
 private function processSource($source)
 {
     $fileSource = new File($source);
     if (!$fileSource->isAbsolute() && !String::startsWith($fileSource->getPath(), Zibo::DIRECTORY_APPLICATION . File::DIRECTORY_SEPARATOR)) {
         $fileSource = Zibo::getInstance()->getFile($fileSource->getPath());
         if (!$fileSource) {
             throw new ZiboException('Could not find ' . $source);
         }
     }
     $fileDestination = $this->getCacheFile($fileSource);
     if (!$fileDestination->exists() || $fileSource->getModificationTime() > $fileDestination->getModificationTime()) {
         $image = new CoreImage($fileSource);
         if ($this->thumbnailer) {
             $thumbnail = $image->thumbnail($this->thumbnailer, $this->thumbnailWidth, $this->thumbnailHeight);
             if ($image === $thumbnail) {
                 $fileSource->copy($fileDestination);
             } else {
                 $thumbnail->write($fileDestination);
             }
         } else {
             $fileSource->copy($fileDestination);
         }
     }
     // remove application/ from the path
     return substr($fileDestination->getPath(), 12);
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:32,代码来源:Image.php

示例10: looksLikeUrl

 /**
  * Checks whether the provided string looks like an HTTP URL
  * @param string $string String to check
  * @return boolean True when the string starts with http:// or https://, false otherwise
  */
 public static function looksLikeUrl($string)
 {
     if (String::startsWith($string, 'http://') || String::startsWith($string, 'https://')) {
         return true;
     }
     return false;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:12,代码来源:Url.php

示例11: bite

 /**
  * Bites a prey to gather the needed information
  * @param WebNode $prey The current node to check
  * @param string $preyBaseUrl The base URL of the prey
  * @param string $preyBasePath The base path of the prey
  * @return null
  */
 private function bite(WebNode $prey, $preyBaseUrl, $preyBasePath)
 {
     $dom = null;
     $response = $prey->getResponse();
     $contentType = $response->getHeader('Content-Type');
     $content = $response->getContent();
     if (String::startsWith($contentType, 'text/html') && $content) {
         $dom = new Document('1.0', 'utf8');
         try {
             $result = @$dom->loadHTML($content);
             if (!$result) {
                 $error = error_get_last();
                 throw new Exception($error['message']);
             }
         } catch (Exception $exception) {
             $prey->setError($exception->getMessage());
         }
     }
     foreach ($this->bites as $bite) {
         $bite->bite($this->web, $prey, $preyBaseUrl, $preyBasePath, $dom);
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:29,代码来源:Spider.php


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