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


PHP Text::startsWith方法代码示例

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


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

示例1: __invoke

 public function __invoke($uri, $query = null, $configKey = 'default')
 {
     if ($query) {
         if (true === is_array($query)) {
             $query = implode(',', $query);
         }
         if (false !== ($pos = strrpos($uri, '.'))) {
             $uri = explode('/', $uri);
             $fileName = array_pop($uri);
             $nameArray = explode('.', $fileName);
             $nameExt = array_pop($nameArray);
             $nameFinal = array_pop($nameArray);
             $nameFinal .= ',' . $query;
             array_push($nameArray, $nameFinal, $nameExt);
             $fileName = implode('.', $nameArray);
             array_push($uri, $fileName);
             $uri = implode('/', $uri);
         }
     }
     if (\Phalcon\Text::startsWith($uri, 'http://', false) || \Phalcon\Text::startsWith($uri, 'https://', false)) {
         return str_replace('http://api.wallstreetcn.com/', 'http://thumbnail.wallstreetcn.com/thumb/', $uri);
     }
     $config = self::getDI()->getConfig();
     if (isset($config->thumbnail->{$configKey}->baseUri) && ($baseUrl = $config->thumbnail->{$configKey}->baseUri)) {
         return $baseUrl . $uri;
     }
     return $uri;
 }
开发者ID:skybird,项目名称:phalcon,代码行数:28,代码来源:WscnThumb.php

示例2: env

 /**
  * Gets the value of an environment variable. Supports boolean, empty and null.
  *
  * @param  string $key
  * @param  mixed $default
  * @return mixed
  */
 function env($key, $default = null)
 {
     $value = getenv($key);
     if ($value === false) {
         return value($default);
     }
     switch (strtolower($value)) {
         case 'true':
         case '(true)':
             return true;
         case 'false':
         case '(false)':
             return false;
         case 'empty':
         case '(empty)':
             return '';
         case 'null':
         case '(null)':
             return;
     }
     if (Text::startsWith($value, '"') && Text::endsWith($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
开发者ID:xueron,项目名称:pails,代码行数:32,代码来源:helper.php

示例3: addFunction

 private function addFunction($jsCode)
 {
     if (!Text::startsWith($jsCode, "function")) {
         $jsCode = "%function(){" . $jsCode . "}%";
     }
     return $jsCode;
 }
开发者ID:jcheron,项目名称:phalcon-jquery,代码行数:7,代码来源:DialogButton.php

示例4: translate

 public function translate($idElement, $key, $default)
 {
     $this->message = "";
     if (Text::startsWith($this->language, "en", true)) {
         return $default;
     }
     $trans = $this->translations->filter(function ($object) use($idElement, $key) {
         if (Text::startsWith($this->language, $object->getLang(), true) && $object->getIdElement() == $idElement && $object->getName() == $key) {
             return $object;
         }
     });
     if (is_array($trans)) {
         if (sizeof($trans) > 0) {
             $trans = $trans[0];
         } else {
             $this->message = $this->translate(1, "translate.info", "");
             return $default;
         }
     }
     if (is_a($trans, "Translation")) {
         return $trans->getText();
     } else {
         $this->message = $this->translate(1, "translate.info", "");
         return $default;
     }
 }
开发者ID:jcheron,项目名称:phalcon-jquery-website,代码行数:26,代码来源:TranslateEngine.php

示例5: setIcons

 /**
  * Icons to display, with or without text (see text option).
  * By default, the primary icon is displayed on the left of the label text and the secondary is displayed on the right.
  * The positioning can be controlled via CSS.
  * The value for the primary and secondary properties must match an icon class name, e.g., "ui-icon-gear".
  * For using only one icon: icons: { primary: "ui-icon-locked" }. For using two icons: icons: { primary: "ui-icon-gear", secondary: "ui-icon-triangle-1-s" }.
  * @param String $value default : { primary: null, secondary: null }
  * @return $this
  */
 public function setIcons($value)
 {
     if (is_string($value)) {
         if (Text::startsWith($value, "{")) {
         }
         $value = "%" . $value . "%";
     }
     return $this->setParam("icons", $value);
 }
开发者ID:jcheron,项目名称:phalcon-jquery,代码行数:18,代码来源:Button.php

示例6: setAjaxSource

 /**
  * Define source property with an ajax request based on $url
  * $url must return a JSON array of values
  * @param String $url
  * @return $this
  */
 public function setAjaxSource($url)
 {
     if (Text::startsWith($url, "/")) {
         $u = $this->js->getDi()->get("url");
         $url = $u->getBaseUri() . $url;
     }
     $ajax = "%function (request, response) {\n\t\t\t\$.ajax({\n\t\t\t\turl: '{$url}',\n\t\t\t\tdataType: 'jsonp',\n\t\t\t\tdata: {q : request.term},\n\t\t\t\tsuccess: function(data) {response(data);}\n\t\t\t});\n\t\t}%";
     return $this->setParam("source", $ajax);
 }
开发者ID:aleboisselier,项目名称:phalcon-jquery,代码行数:15,代码来源:Autocomplete.php

示例7: parseDefinitionArgument

 private function parseDefinitionArgument($argument)
 {
     if (Text::startsWith($argument, '!')) {
         return ['type' => 'parameter', 'value' => Arr::path($this->config->toArray(), substr($argument, 1))];
     } elseif (Text::startsWith($argument, '@')) {
         return ['type' => 'service', 'name' => substr($argument, 1)];
     } else {
         return ['type' => 'parameter', 'value' => $argument];
     }
 }
开发者ID:nexik,项目名称:nest-core,代码行数:10,代码来源:ServiceParser.php

示例8: testStartsWith

 public function testStartsWith()
 {
     $this->assertFalse(PhText::startsWith("", ""));
     $this->assertFalse(PhText::startsWith("", "hello"));
     $this->assertTrue(PhText::startsWith("Hello", "H"));
     $this->assertTrue(PhText::startsWith("Hello", "He"));
     $this->assertTrue(PhText::startsWith("Hello", "Hello"));
     $this->assertFalse(PhText::startsWith("Hello", "hel"));
     $this->assertFalse(PhText::startsWith("Hello", "hello"));
     $this->assertFalse(PhText::startsWith("Hello", "hello", true));
     $this->assertTrue(PhText::startsWith("Hello", "hello", false));
     $this->assertTrue(PhText::startsWith("Hello", "h", false));
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:13,代码来源:UnitTest.php

示例9: queryKeys

 /**
  * Query the existing cached keys
  *
  * @param string|null $prefix
  * @return array
  */
 public function queryKeys($prefix = null)
 {
     if (is_null($prefix) === false) {
         $prefix = (string) $prefix;
     }
     if (is_array($this->_data) === true) {
         if (is_null($prefix) === true) {
             return array_keys($this->_data);
         }
         $result = array();
         foreach ($this->_data as $key => $value) {
             if (Text::startsWith($key, $prefix) === true) {
                 $result[] = $key;
             }
         }
         return $result;
     }
     //@note The default implementation returns NULL
     return array();
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:26,代码来源:Memory.php

示例10: isLocal

 public function isLocal()
 {
     return !Text::startsWith($this->getUrl(), 'http');
 }
开发者ID:Oscailte,项目名称:phlame,代码行数:4,代码来源:Stylesheet.php

示例11: startsWith

 public static function startsWith($str, $start, $ignoreCase = null)
 {
     return Text::startsWith($str, $start, $ignoreCase);
 }
开发者ID:aleboisselier,项目名称:phalcon-jquery,代码行数:4,代码来源:PhalconUtils.php

示例12: queryKeys

 /**
  * Query the existing cached keys
  *
  * @param string|null $prefix
  * @return array
  * @throws Exception
  */
 public function queryKeys($prefix = null)
 {
     if (is_string($prefix) === false && is_null($prefix) === false) {
         throw new Exception('Invalid parameter type.');
     }
     $keys = array();
     //We use a directory iterator to traverse the cache dir directory
     $ce = new DirectoryIterator($this->_options['cacheDir']);
     if (is_null($prefix) === false) {
         //Prefix is set
         foreach ($ce as $item) {
             if (is_dir($item) === false) {
                 $key = $item->getFileName();
                 if (Text::startsWith($key, $prefix) === false) {
                     continue;
                 }
                 $keys[] = $key;
             }
         }
     } else {
         //Without using a prefix
         foreach ($ce as $item) {
             if (is_dir($item) === false) {
                 $keys[] = $item->getFileName();
             }
         }
     }
     return $keys;
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:36,代码来源:File.php

示例13: autoLoad

 /**
  * Makes the work of autoload registered classes
  *
  * @param string $className
  * @return boolean
  */
 public function autoLoad($className)
 {
     $eventsManager = $this->_eventsManager;
     if (is_object($eventsManager) === true) {
         $eventsManager->fire('loader:beforeCheckClass', $this, $className);
     }
     /* First we check for static paths */
     if (is_array($this->_classes) === true && isset($this->_classes[$className]) === true) {
         $filePath = $this->_classes[$className];
         if (is_object($eventsManager) === true) {
             $this->_foundPath = $filePath;
             $eventsManager->fire('loader:pathFound', $this, $filePath);
         }
         require_once $filePath;
         return true;
     }
     $extensions = $this->_extensions;
     /* Checking in namespaces */
     if (is_array($this->_namespaces) === true) {
         foreach ($this->_namespaces as $nsPrefix => $directory) {
             //The class name must start with the current namespace
             if (Text::startsWith($className, $nsPrefix) === true) {
                 //Get the possible file path
                 $fileName = self::possibleAutoloadFilePath($nsPrefix, $className, \DIRECTORY_SEPARATOR, null);
                 if ($fileName !== false) {
                     //Add a trailing directory separator is the user forgot to do that
                     $fixedDirectory = self::fixPath($directory, \DIRECTORY_SEPARATOR);
                     foreach ($extensions as $extension) {
                         $filePath = $fixedDirectory . $fileName . '.' . $extension;
                         //Check if an events manager is available
                         if (is_object($eventsManager) === true) {
                             $this->_checkedPath = $filePath;
                             $eventsManager->fire('loader:beforeCheckPath', $this);
                         }
                         //This is probably a good path, let's check if the file exists
                         if (file_exists($filePath) === true) {
                             if (is_object($eventsManager) === true) {
                                 $this->_foundPath = $filePath;
                                 $eventsManager->fire('loader:pathFound', $this, $filePath);
                             }
                             require_once $filePath;
                             //Return true means success
                             return true;
                         }
                     }
                 }
             }
         }
     }
     /* Checking in prefixes */
     $prefixes = $this->_prefixes;
     if (is_array($prefixes) === true) {
         foreach ($prefixes as $prefix => $directory) {
             //The class name starts with the prefix?
             if (Text::startsWith($className, $prefix) === true) {
                 //Get the possible file path
                 $fileName = self::possibleAutoloadFilePath($prefix, $className, \DIRECTORY_SEPARATOR, '_');
                 if ($fileName !== false) {
                     //Add a trailing directory separator is the user forgot to do that
                     $fixedDirectory = self::fixPath($directory, \DIRECTORY_SEPARATOR);
                     foreach ($extensions as $extension) {
                         $filePath = $fixedDirectory . $fileName . '.' . $extension;
                         if (is_object($eventsManager) === true) {
                             $this->_checkedPath = $filePath;
                             $eventsManager->fire('loader:beforeCheckPath', $this, $filePath);
                         }
                         if (file_exists($filePath) === true) {
                             //Call 'pathFound' event
                             if (is_object($eventsManager) === true) {
                                 $this->_foundPath = $filePath;
                                 $eventsManager->fire('loader:pathFound', $this, $filePath);
                             }
                             require_once $filePath;
                             return true;
                         }
                     }
                 }
             }
         }
     }
     //Change the pseudo-separator by the directory separator in the class name
     $dsClassName = str_replace('_', \DIRECTORY_SEPARATOR, $className);
     //And change the namespace separator by directory separator too
     $nsClassName = str_replace('\\', \DIRECTORY_SEPARATOR, $dsClassName);
     /* Checking in directories */
     $directories = $this->_directories;
     if (is_array($directories) === true) {
         foreach ($directories as $directory) {
             //Add a trailing directory separator if the user forgot to do that
             $fixedDirectory = self::fixPath($directory, \DIRECTORY_SEPARATOR);
             foreach ($extensions as $extension) {
                 //Create a possible path for the file
                 $filePath = $fixedDirectory . $nsClassName . '.' . $extension;
                 if (is_object($eventsManager) === true) {
//.........这里部分代码省略.........
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:101,代码来源:Loader.php

示例14: startsWith

 public static function startsWith($str, $start, $ignoreCase = true)
 {
     return parent::startsWith($str, $start, $ignoreCase);
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:4,代码来源:Text.php

示例15: assetType

 public function assetType($src)
 {
     if (Text::startsWith($src, 'http')) {
         return 'remote';
     }
     if (Text::startsWith($src, 'files/')) {
         return 'local';
     }
     return 'inline';
 }
开发者ID:Oscailte,项目名称:phlame,代码行数:10,代码来源:Doc.php


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