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


PHP String::endsWith方法代码示例

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


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

示例1: auto

 /**
  * Handles autoloading PHP classes. This is the default way for all classes to be
  * loaded in Caffeine.
  *
  * This method is called due to spl_autoload_register() being set to this method.
  *
  * Module Format:
  *      MyModule = mymodule/mymodule.php
  *
  * Module Sub-Class Format:
  *      MyModule_Foo = mymodule/mymodule_foo.php
  *      MyModule_FooBar = mymodule/mymodule_foo_bar.php
  *
  * Controller Format:
  *      MyModule_HelloController = mymodule/controllers/hello.php
  *      MyModule_HelloWorldController = mymodule/controllers/hello_world.php
  *      MyModule_Hello_World_Controller = mymodule/controllers/hello_world.php
  *
  * Model Format:
  *      Same as controller format, except replace "Controller" with "Model" in class names.
  *
  * @param string $class The class name to find and attempt to load.
  */
 public static function auto($class)
 {
     $dir = strtolower($class);
     $file = $dir;
     // Class contains underscore, determine if its a sub class, controller or model
     if (strstr($class, '_')) {
         $bits = explode('_', $class, 2);
         // Only explode first underscore, ignore rest
         $dir = strtolower($bits[0]);
         // Check for controller
         if (String::endsWith($bits[1], 'Controller')) {
             $file = self::_formatController($bits[1]);
         } elseif (String::endsWith($bits[1], 'Model')) {
             $file = self::_formatModel($bits[1]);
         } else {
             $file = $dir . '_' . self::_formatSubClass($bits[1]);
         }
     }
     foreach (self::$_modulePaths as $path) {
         $filePath = sprintf('%s%s/%s%s', $path, $dir, $file, EXT);
         if (file_exists($filePath)) {
             require_once $filePath;
             return;
         }
     }
 }
开发者ID:simudream,项目名称:caffeine,代码行数:49,代码来源:load.php

示例2: __construct

 /**
  * @param string $glob
  */
 public function __construct($glob)
 {
     if (String::endsWith('/', $glob)) {
         $glob .= '**';
     }
     $this->glob = $glob;
 }
开发者ID:wjdhollow,项目名称:antglob,代码行数:10,代码来源:AntGlob.php

示例3: hasSuffix

 /**
  * has filename required suffix?
  *
  * @param string
  * @param string
  * @return bool
  */
 public static function hasSuffix($filename, $suffix)
 {
     //		if (preg_match("/.*\.$suffix$/", $filename)) {
     //			return TRUE;
     //		}
     //		return FALSE;
     return String::endsWith($filename, ".{$suffix}");
 }
开发者ID:radypala,项目名称:maga-website,代码行数:15,代码来源:FileModel.php

示例4: testEndswith

 /**
  * endsWith test.
  * @return void
  */
 public function testEndswith()
 {
     $this->assertTrue(String::endsWith('123', NULL), "String::endsWith('123', NULL)");
     $this->assertTrue(String::endsWith('123', ''), "String::endsWith('123', '')");
     $this->assertTrue(String::endsWith('123', '3'), "String::endsWith('123', '3')");
     $this->assertFalse(String::endsWith('123', '2'), "String::endsWith('123', '2')");
     $this->assertTrue(String::endsWith('123', '123'), "String::endsWith('123', '123')");
     $this->assertFalse(String::endsWith('123', '1234'), "String::endsWith('123', '1234')");
 }
开发者ID:vrana,项目名称:nette,代码行数:13,代码来源:NetteStringTest.php

示例5: ucfirst

 /**
  * Returns property value. Do not call directly.
  * support for models [e.g. rolesModel]
  * @param  string  property name
  * @return mixed   property value
  */
 public function &__get($name)
 {
     $className = ucfirst($name);
     if (String::endsWith($className, 'Model') && class_exists($className)) {
         if (!isset(self::$models[$className])) {
             self::$models[$className] = new $className();
         }
         return self::$models[$className];
     }
     return parent::__get($name);
 }
开发者ID:radypala,项目名称:maga-website,代码行数:17,代码来源:BaseModel.php

示例6: setPropositionLayer

 public function setPropositionLayer()
 {
     $propositionResult = false;
     if ($this->visualization[REQUEST_PARAMETER_MYMAP]) {
         $vizJSON = $this->getVisualizationJSON();
         $propositionsLayer = array();
         if (isset($vizJSON['layers'])) {
             $layer = end($vizJSON['layers']);
             if (isset($layer['type']) && $layer['type'] === 'layergroup') {
                 foreach ($layer['options']['layer_definition']['layers'] as $groupLayer) {
                     // substr: remove the date from the end of the layer name (Ymd_His)
                     if (isset($groupLayer['options']['layer_name']) && String::endsWith(substr($groupLayer['options']['layer_name'], 0, -16), '_propose')) {
                         $propositionsLayer = $groupLayer;
                         break;
                     }
                 }
             }
         }
         if (!$propositionsLayer) {
             $vizResult = Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v1/viz/%s?api_key=%s', $this->user['UserName'], $this->visualization[REQUEST_PARAMETER_VIZ_ID], $this->user['ApiKey']));
             if ($vizResult) {
                 $visualization = json_decode($vizResult, true);
                 if (isset($visualization['related_tables'])) {
                     $table = reset($visualization['related_tables']);
                     $tableId = $table['id'];
                     $tableResult = Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v1/tables/%s?api_key=%s', $this->user['UserName'], $tableId, $this->user['ApiKey']));
                     if ($tableResult) {
                         $originalTable = json_decode($tableResult, true);
                         // substr: retrieve the base table name and date from the original table name (Ymd_His)
                         $originalName = substr($originalTable['name'], 0, -16);
                         $originalDate = substr($originalTable['name'], -15);
                         // the_geom_type: geometry, multipolygon, point, multilinestring
                         $createTableResult = Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v1/tables?api_key=%s', $this->user['UserName'], $this->user['ApiKey']), array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('name' => substr($originalName, 0, 22) . '_propose_' . $originalDate, 'description' => __('Update propositions for %s', $originalTable['name']), 'tags' => 'update,propose,propositions')));
                         if ($createTableResult) {
                             $newTable = json_decode($createTableResult, true);
                             $newTableName = $newTable['name'];
                             Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v1/tables/%s?api_key=%s', $this->user['UserName'], $newTable['id'], $this->user['ApiKey']), array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POSTFIELDS => json_encode(array('privacy' => 'PUBLIC'))));
                             Connectivity::closeCurl();
                             $columns = array(' ADD COLUMN user_id text NOT NULL', ' ADD COLUMN visualization_id text NOT NULL', ' ADD COLUMN column_data text', ' ADD COLUMN the_geom_old geometry');
                             $columnQuery = "ALTER TABLE \"{$newTableName}\"" . implode(',', $columns) . ';';
                             $sqlResult = Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v2/sql', $this->user['UserName']), array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('q' => $columnQuery, 'api_key' => $this->user['ApiKey'])));
                             $layerParams = array('kind' => 'carto', 'order' => 2, 'options' => array('table_name' => $newTableName, 'user_name' => $this->user['UserName'], 'interactivity' => 'cartodb_id', 'visible' => false, 'style_version' => '2.1.1', 'tile_style' => "#{$newTableName} {\n        // points\n        [mapnik-geometry-type=point] {\n                marker-fill: #77BBDD;\n                marker-opacity: 0.5;\n                marker-width: 12;\n                marker-line-color: #222222;\n                marker-line-width: 3;\n                marker-line-opacity: 1;\n                marker-placement: point;\n                marker-type: ellipse;\n                marker-allow-overlap: true;\n        }\n\n        //lines\n        [mapnik-geometry-type=linestring] {\n                line-color: #77BBDD;\n                line-width: 2;\n                line-opacity: 0.5;\n        }\n\n        //polygons\n        [mapnik-geometry-type=polygon] {\n                polygon-fill: #77BBDD;\n                polygon-opacity: 0.5;\n                line-opacity: 1;\n                line-color: #222222;\n        }\n}"));
                             $layerCreateResult = Connectivity::runCurl(String::prepare('http://%s.spotzi.me/api/v1/maps/%s/layers?api_key=%s', $this->user['UserName'], $visualization['map_id'], $this->user['ApiKey']), array(CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POSTFIELDS => json_encode($layerParams)));
                             $propositionResult = (bool) $layerCreateResult;
                         }
                     }
                 }
             }
         }
     }
     return array(REQUEST_RESULT => $propositionResult);
 }
开发者ID:geo4web-testbed,项目名称:topic2,代码行数:52,代码来源:PropositionModel.php

示例7: isTestActionFilter

 private function isTestActionFilter($name)
 {
     return String::endsWith($name, 'TestAction');
 }
开发者ID:fkali,项目名称:yupp,代码行数:4,代码来源:apps.tests.controllers.HelpersTestController.class.php

示例8: endsWith

 /**
  * @test
  */
 public function endsWith()
 {
     $this->assertTrue(String::endsWith('Foo', 'Foo'));
     $this->assertTrue(String::endsWith('Foo123', '123'));
     $this->assertFalse(String::endsWith(' Foo123 ', '123'));
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:9,代码来源:StringTest.php

示例9: handleUpload

 /**
  * Handle a file uploaded by the client.
  *
  * @param       string          $targetDirectory        Target directory
  * @param       string          $parameterName          Parameter name as used in the form element
  * @param       string          $fileName               Target file name (optional)
  * @param       array           $allowedTypes           List containing allowed file types (optional)
  * @param       int             $sizeLimit              File size limit in bytes (optional)
  * @return      boolean                                 True on success, false otherwise
  */
 public static function handleUpload($targetDirectory, $parameterName, $fileName = null, $allowedTypes = array(), $sizeLimit = 512000)
 {
     if (!String::endsWith($targetDirectory, '/')) {
         $targetDirectory = "{$targetDirectory}/";
     }
     $files = $_FILES;
     if (empty($files) || !file_exists($targetDirectory) && !mkdir($targetDirectory, 0777, true)) {
         return false;
     }
     foreach ($files as $index => $fileCollection) {
         if (is_array($files[$index]['name'])) {
             $files[$index] = Collection::diverse($fileCollection);
         }
     }
     $bracketStartPos = strpos($parameterName, '[');
     if ($bracketStartPos) {
         $bracketEndPos = strpos($parameterName, ']');
         $parameterCollection = substr($parameterName, 0, $bracketStartPos);
         $parameterName = substr($parameterName, $bracketStartPos + 1, $bracketEndPos - $bracketStartPos - 1);
         $file = isset($files[$parameterCollection][$parameterName]) ? $files[$parameterCollection][$parameterName] : false;
     } else {
         $file = isset($files[$parameterName]) ? $files[$parameterName] : false;
     }
     if (!$file || $file['error'] !== UPLOAD_ERR_OK || !empty($allowedTypes) && !in_array($file['type'], $allowedTypes) || $sizeLimit > 0 && $file['size'] > $sizeLimit) {
         return false;
     }
     if (!$fileName) {
         $fileName = basename($file['name']);
     }
     return move_uploaded_file($file['tmp_name'], $targetDirectory . $fileName) ? $fileName : false;
 }
开发者ID:geo4web-testbed,项目名称:topic2,代码行数:41,代码来源:File.php

示例10: _text

                if (!doesHaveMembership() && isLoginId(getBlogId(), $_POST['loginid'])) {
                    $showPasswordReset = true;
                }
            } else {
                if (!doesHaveOwnership()) {
                    $message = _text('서비스의 회원이지만 이 블로그의 구성원이 아닙니다. 주소를 확인해 주시기 바랍니다.');
                }
            }
        }
    }
}
$authResult = fireEvent('LOGIN_try_auth', false);
if (doesHaveOwnership() || doesHaveMembership()) {
    if (doesHaveOwnership() && !empty($_POST['requestURI'])) {
        $url = parse_url($_POST['requestURI']);
        if ($url && isset($url['host']) && !String::endsWith('.' . $url['host'], '.' . $context->getProperty('service.domain'))) {
            $redirect = $context->getProperty('uri.blog') . "/login?requestURI=" . rawurlencode($_POST['requestURI']) . '&session=' . rawurlencode(session_id());
        } else {
            $redirect = $_POST['requestURI'];
        }
    } else {
        $redirect = $_POST['refererURI'];
    }
    if (empty($_SESSION['lastloginRedirected']) || $_SESSION['lastloginRedirected'] != $redirect) {
        $_SESSION['lastloginRedirected'] = $redirect;
    } else {
        unset($_SESSION['lastloginRedirected']);
    }
    header('Location: ' . $redirect);
    exit;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:31,代码来源:index.php

示例11: flashHandler

 /**
  * Flash handler for images
  *
  * @example [* flash.swf 200x150 .(alternative content) *]
  *
  * @param TexyHandlerInvocation  handler invocation
  * @param TexyImage
  * @param TexyLink
  * @return TexyHtml|string|FALSE
  */
 public function flashHandler($invocation, $image, $link)
 {
     if (!String::endsWith($image->URL, ".swf")) {
         return $invocation->proceed();
     }
     $template = $this->createTemplate()->setFile(APP_DIR . "/templates/inc/@flash.phtml");
     $template->url = Texy::prependRoot($image->URL, $this->imageModule->root);
     $template->width = $image->width;
     $template->height = $image->height;
     if ($image->modifier->title) {
         $template->title = $image->modifier->title;
     }
     return $this->protect((string) $template, Texy::CONTENT_BLOCK);
 }
开发者ID:regiss,项目名称:texyla-s-Nete1-PhP-5.2,代码行数:24,代码来源:MyTexy.php

示例12: testEndsWith

 /**
  * @covers Panadas\Util\String::endsWith()
  */
 public function testEndsWith()
 {
     $this->assertTrue(String::endsWith("bar", "foobar"));
     $this->assertFalse(String::endsWith("foo", "foobar"));
 }
开发者ID:panadas,项目名称:util,代码行数:8,代码来源:StringTest.php

示例13: endsWith

 public function endsWith()
 {
     $str = new String('www.m�ller.com');
     $this->assertTrue($str->endsWith('.com'));
     $this->assertTrue($str->endsWith('�ller.com'));
     $this->assertFalse($str->endsWith('.co'));
     $this->assertFalse($str->endsWith('m�ller'));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:8,代码来源:StringTest.class.php

示例14: testEndsWith5

 /**
  * Generated from @assert ("", "abcdef") == false.
  *
  * @covers String::endsWith
  */
 public function testEndsWith5()
 {
     $this->assertFalse(String::endsWith("", "abcdef"));
 }
开发者ID:Jadoube-Initiative,项目名称:phpPGN,代码行数:9,代码来源:StringTest.php

示例15: useFile

 public function useFile($file)
 {
     $file = CONFIG_PATH . $file;
     if (file_exists($file)) {
         // need extra string utilities
         $fileStr = new String($file);
         if ($fileStr->endsWith('.ser')) {
             // serialize
             $configIn = unserialize(file_get_contents($file));
             if ($configIn === false) {
                 return self::$LOAD_ERR;
             } else {
                 self::$cache[$file] = array_merge(self::$cache[$file], $configIn);
                 return yes;
             }
         } else {
             if ($fileStr->endsWith('.json')) {
                 // json
                 $configIn = json_decode(file_get_contents($file), yes);
                 if ($configIn === null) {
                     return self::$LOAD_ERR;
                 } else {
                     self::$cache[$file] = array_merge(self::$cache[$file], $configIn);
                     return yes;
                 }
             } else {
                 return self::$NO_METHOD;
             }
         }
     } else {
         return self::$FILE_DNE;
     }
 }
开发者ID:ryanknu,项目名称:zule-framework,代码行数:33,代码来源:Config.php


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