當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。