本文整理汇总了PHP中String类的典型用法代码示例。如果您正苦于以下问题:PHP String类的具体用法?PHP String怎么用?PHP String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: declareParameters
public function declareParameters()
{
$track = new String('track');
$track->setValidateType('int');
$album = new String('album');
$album->setValidateType('int');
$this->source = new XorParameter('source');
$this->source->addParameter($track);
$this->source->addParameter($album);
$this->source->setRequired();
$this->source->setDefaultParameter($track);
$this->addParameter($this->source);
$this->autoplay = new Boolean('autoplay');
$this->addParameter($this->autoplay);
$this->lang = new XorParameter('lang');
$this->lang->addParameter(new Option('en'));
$this->lang->addParameter(new Option('fr'));
$this->lang->setDefaultValue('en');
$this->addParameter($this->lang);
$float = new XorParameter('float');
$this->right = new Option('right');
$float->addParameter($this->right);
$this->left = new Option('left');
$float->addParameter($this->left);
$this->addParameter($float);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:26,代码来源:Jamendo.php
示例2: ShowProduct
function ShowProduct($id_product)
{
$objResponse = new xajaxResponse();
$bError = false;
$stringutil = new String("");
$tempname = "en_title";
$tempdescription = "en_detaileddescription";
$SQL = "SELECT {$tempname},{$tempdescription} FROM " . DB_PREFIX . "product WHERE id_product='" . $id_product . "'";
//$objResponse->addAlert($SQL);
$retid = mysql_query($SQL);
if (!$retid) {
echo mysql_error();
}
if ($row = mysql_fetch_array($retid)) {
$name = $row[$tempname];
$description = $stringutil->cleanDescription2($row[$tempdescription]);
}
$ft = new FastTemplate(TEMPLATE_PATH);
$ft->define(array("main" => "product_rightmenu.html"));
$ft->assign("NAME", $name);
//if (NONSEO==1) $ft->assign("URL_TYPE", "product.php?name=".$stringutil->CleanLink($name)."&id=".$id_product."");
//else $ft->assign("URL_TYPE", "product.php/".$stringutil->CleanLink($name)."/".$id_product."/");
$ft->assign("DESCRIPTION", $description);
$ft->multiple_assign_define("LANG_");
$ft->parse("mainContent", "main");
$ft->showDebugInfo(ERROR_DEBUG);
$c = $ft->fetch("mainContent");
//$objResponse->addAlert($c);
$objResponse->addAssign("body_firstpage_background_right", "innerHTML", $c);
return $objResponse;
}
开发者ID:nciftci,项目名称:codefaster,代码行数:31,代码来源:how-to.php
示例3: testNoMatch
function testNoMatch()
{
$input = new String("blaat");
$pattern = "|<[^>]+>(.*)</[^>]+>|U";
$matches = $input->getMatches($pattern);
$this->assertEqual(0, $matches->size());
}
开发者ID:aeberh,项目名称:php-movico,代码行数:7,代码来源:StringMatchesTest.php
示例4: addHtml
/**
* Inject HTML in the navigation element
*
* @param string $html The HTML string
* @return \ValidFormBuilder\String
*/
public function addHtml($html)
{
$objString = new String($html);
$objString->setMeta("parent", $this, true);
$this->__fields->addObject($objString);
return $objString;
}
开发者ID:SLivio,项目名称:validformbuilder,代码行数:13,代码来源:Navigation.php
示例5: declareParameters
protected function declareParameters()
{
$this->source = new XorParameter('source');
$email = new String('email');
$email->setValidateType('email');
$this->source->addParameter($email);
$user = new User('user');
$this->source->addParameter($user);
$this->source->setDefaultParameter($user);
global $wgUser;
$this->source->setDefaultValue($wgUser, false);
$this->addParameter($this->source);
$this->size = new IntegerInPixel('size');
global $wgWFMKMaxWidth;
$this->size->setMax(min(array($wgWFMKMaxWidth, 2048)));
$this->size->setDefaultValue(80);
$this->addParameter($this->size);
/*
* Currently, rating is forced to G: "suitable for display on all websites with any audience type"
$this->rating = new XorParameter('rating');
$this->rating->addParameter(new Option('g')); // +++ all websites with any audience type
$this->rating->addParameter(new Option('pg')); // ++
$this->rating->addParameter(new Option('r')); // +
$this->rating->addParameter(new Option('x')); // ! hardcore
$this->addParameter($this->rating);
*/
$float = new XorParameter('float');
$this->right = new Option('right');
$float->addParameter($this->right);
$this->left = new Option('left');
$float->addParameter($this->left);
$this->addParameter($float);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:33,代码来源:Gravatar.php
示例6: declareParameters
/**
* Declares the widget's parameters:
* <ul>
* <li>instanciates Parameter objects,</li>
* <li>configures them and</li>
* <li>calls addParameter() for each of them.</li>
* </ul>
*
* @return void
*/
protected function declareParameters()
{
global $wgWFMKMaxWidth;
$user = new String('user');
$user->setEscapeMode('quotes');
$search = new String('search');
$search->setEscapeMode('quotes');
$this->source = new XorParameter('source');
$this->source->addParameter($user);
$this->source->addParameter($search);
$this->source->setRequired();
// one of theses parameters has to be set
$this->source->setDefaultParameter($user);
// user don't need to type "user=xxx", just "xxx" at right position
$this->addParameter($this->source);
$this->faves = new Option('faves');
$this->list = new String('list');
$this->list->setEscapeMode('quotes');
$this->follow = new Option('follow');
$mode = new XorParameter('mode');
$mode->addParameter($this->faves);
$mode->addParameter($this->list);
$mode->addParameter($this->follow);
$this->addParameter($mode);
$this->title = new String('title');
$this->title->setEscapeMode('quotes');
$this->addParameter($this->title);
$this->subject = new String('subject');
$this->subject->setEscapeMode('quotes');
$this->addParameter($this->subject);
$this->width = new IntegerInPixel('width');
$this->width->setDefaultValue($wgWFMKMaxWidth);
$this->width->setMin(0);
$this->width->setMax($wgWFMKMaxWidth);
$this->addParameter($this->width);
$this->height = new IntegerInPixel('height');
$this->height->setDefaultValue(441);
$this->height->setMin(0);
$this->addParameter($this->height);
$this->count = new Integer('count');
$this->count->setDefaultValue(5);
$this->count->setMin(0);
$this->count->setMax(30);
$this->addParameter($this->count);
$this->scrollbar = new Boolean('scrollbar');
$this->addParameter($this->scrollbar);
$this->live = new Boolean('live');
$this->addParameter($this->live);
$this->loop = new Boolean('loop');
$this->addParameter($this->loop);
$this->all = new Boolean('all');
$this->addParameter($this->all);
$float = new XorParameter('float');
$this->right = new Option('right');
$float->addParameter($this->right);
$this->left = new Option('left');
$float->addParameter($this->left);
$this->addParameter($float);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:69,代码来源:Twitter.php
示例7: setParam
public function setParam($nm, $val)
{
assert(isset($this->sth));
//no use to set param before calling prepare
$snm = new String($nm);
$this->params[$snm->prepend(':')] = $val;
return $this;
}
开发者ID:sd-studio,项目名称:or,代码行数:8,代码来源:db_pdo.php
示例8: getParent
public function getParent()
{
$result = new String($this->m_sFilename);
if ($result->lastIndexOf(new java_lang_String("/")) > -1) {
return $result->substring(0, $result->lastIndexOf(new String("/")));
} else {
return Translator_JavaBase::$null;
}
}
开发者ID:glegris,项目名称:java2php,代码行数:9,代码来源:File.class.php
示例9: __construct
/**
* @param string|int $string
*/
public function __construct($string = null)
{
if (is_int($string)) {
parent::__construct($string);
return;
}
$string = new String($string);
parent::__construct($string->length() + 16);
$this->append($string);
}
开发者ID:phpj,项目名称:phpj,代码行数:13,代码来源:StringBuilder.php
示例10: testStringProperty
public function testStringProperty()
{
$validString = 'ABCDEFGHIJKLMNOP';
$invalidString = 'ABCDEFGHIJKLMNOPQR';
$property = new String('Name', null, 16);
$property->setValue($validString);
$this->assertEquals($validString, $property->getValue());
$property->setValue($invalidString);
$this->assertEquals(16, strlen($property->getValue()));
}
开发者ID:rickyrobinett,项目名称:morph,代码行数:10,代码来源:TestProperties.php
示例11: itShouldConcatinateStrings
/**
* @test
* Enter description here...
* @return unknown_type
*/
public function itShouldConcatinateStrings()
{
$array = array("I have", " a enumerable object ", "of strings");
$start = new String("notice:");
$container = $start->concat(" this is a test. ");
foreach ($array as $value) {
$container = $container->concat($value);
}
$this->expectsThat($start)->equals("notice:");
$this->expectsThat($container)->equals("notice: this is a test. I have a enumerable object of strings");
}
开发者ID:amptools-net,项目名称:midori-php,代码行数:16,代码来源:StringSpec.php
示例12: funname
public function funname()
{
import('@.ORG.String');
/**
* 生成随机名称
*/
$str = new String();
$name = $str->uuid();
$name = str_replace("}", "", $name);
$name = str_replace("{", "", $name);
return $name;
}
开发者ID:ycltpe,项目名称:sig,代码行数:12,代码来源:LoginImgAction.class.php
示例13: quoteInto
protected static function quoteInto($sql)
{
if (func_num_args() == 1) {
return $sql;
}
$sql = new String($sql);
$args = func_get_args();
$args = array_slice($args, 1);
foreach ($args as $i => $arg) {
$sql->{$i} = $arg;
}
return $sql->__toString();
}
开发者ID:joksnet,项目名称:php-old,代码行数:13,代码来源:Db.php
示例14: particularidade
/**
* particularidade() Faz em tempo de execução mudanças que sejam imprescindíveis
* para a geração correta do código de barras
* Particularmente para o Banrisul, ele acrescenta ao array OB::$Data, que
* guarda as variáveis que geram o código de barras, uma nova variável
* $DuploDigito, específica desse banco
*
* @version 0.1 28/05/2011 Initial
*/
public function particularidade($object)
{
$codigo = String::insert('21:Agencia:CodigoCedente:NossoNumero041', $object->Data);
$dv1 = Math::Mod10($codigo);
$dv2 = Math::Mod11($codigo . $dv1);
return $object->Data['DuploDigito'] = self::DuploDigito($codigo);
}
开发者ID:nunomazer,项目名称:PHP-Object-Boleto,代码行数:16,代码来源:Banrisul.php
示例15: parseTypeName
/**
* @see TypeDescription::parseTypeName()
*/
function parseTypeName($typeName)
{
// Standard validators are based on string input.
parent::parseTypeName('string');
// Split the type name into validator name and arguments.
$typeNameParts = explode('(', $typeName, 2);
switch (count($typeNameParts)) {
case 1:
// no argument
$this->_validatorArgs = '';
break;
case 2:
// parse arguments (no UTF8-treatment necessary)
if (substr($typeNameParts[1], -1) != ')') {
return false;
}
// FIXME: Escape for PHP code inclusion?
$this->_validatorArgs = substr($typeNameParts[1], 0, -1);
break;
}
// Validator name must start with a lower case letter
// and may contain only alphanumeric letters.
if (!String::regexp_match('/^[a-z][a-zA-Z0-9]+$/', $typeNameParts[0])) {
return false;
}
// Translate the validator name into a validator class name.
$this->_validatorClassName = 'Validator' . String::ucfirst($typeNameParts[0]);
return true;
}
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:32,代码来源:ValidatorTypeDescription.inc.php
示例16: slug
/**
* Returns a string with all spaces converted to $replacement and non word characters removed.
*
* @param string $string
* @param string $replacement
* @return string
* @static
*/
static function slug($string, $replacement = '-')
{
$string = trim($string);
$map = array('/à|á|å|â|ä/' => 'a', '/è|é|ê|ẽ|ë/' => 'e', '/ì|í|î/' => 'i', '/ò|ó|ô|ø/' => 'o', '/ù|ú|ů|û/' => 'u', '/ç|č/' => 'c', '/ñ|ň/' => 'n', '/ľ/' => 'l', '/ý/' => 'y', '/ť/' => 't', '/ž/' => 'z', '/š/' => 's', '/æ/' => 'ae', '/ö/' => 'oe', '/ü/' => 'ue', '/Ä/' => 'Ae', '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/ß/' => 'ss', '/[^\\w\\s]/' => ' ', '/\\s+/' => $replacement, String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => '');
$string = preg_replace(array_keys($map), array_values($map), $string);
return low($string);
}
开发者ID:uuking,项目名称:wildflower,代码行数:15,代码来源:app_helper.php
示例17: compile
/**
* Generate the content element
*/
protected function compile()
{
global $objPage;
// Clean the RTE output
if ($objPage->outputFormat == 'xhtml') {
$this->text = \String::toXhtml($this->text);
} else {
$this->text = \String::toHtml5($this->text);
}
// Add the static files URL to images
if (TL_FILES_URL != '') {
$path = $GLOBALS['TL_CONFIG']['uploadPath'] . '/';
$this->text = str_replace(' src="' . $path, ' src="' . TL_FILES_URL . $path, $this->text);
}
$this->Template->text = \String::encodeEmail($this->text);
$this->Template->addImage = false;
// Add an image
if ($this->addImage && $this->singleSRC != '') {
if (!is_numeric($this->singleSRC)) {
$this->Template->text = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
} else {
$objModel = \FilesModel::findByPk($this->singleSRC);
if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
$this->singleSRC = $objModel->path;
$this->addImageToTemplate($this->Template, $this->arrData);
}
}
}
}
开发者ID:rburch,项目名称:core,代码行数:32,代码来源:ContentText.php
示例18: main
function main()
{
if (empty($this->args)) {
return $this->err('Usage: ./cake uuidize <table>');
}
if ($this->args[0] == '?') {
return $this->out('Usage: ./cake uuidize <table> [-force] [-reindex]');
}
$options = array('force' => false, 'reindex' => false);
foreach ($this->params as $key => $val) {
foreach ($options as $name => $option) {
if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
$options[$name] = true;
}
}
}
foreach ($this->args as $table) {
$name = Inflector::classify($table);
$Model = new AppModel(array('name' => $name, 'table' => $table));
$records = $Model->find('all');
foreach ($records as $record) {
$Model->updateAll(array('id' => '"' . String::uuid() . '"'), array('id' => $record[$name]['id']));
}
}
}
开发者ID:stripthis,项目名称:donate,代码行数:25,代码来源:uuidize.php
示例19: testGiftsAddRedirectsIfNoValidAppealGiven
/**
* undocumented function
*
* @return void
* @access public
*/
function testGiftsAddRedirectsIfNoValidAppealGiven()
{
$this->fakeRequest('get');
$this->Sut->params['named']['appeal_id'] = '';
$this->Sut->add();
$this->is($this->Sut->redirectUrl, '/');
// any non existant appeal id
$this->Sut->redirectUrl = '';
$this->Sut->params['named']['appeal_id'] = String::uuid();
$this->Sut->add();
$this->is($this->Sut->redirectUrl, '/');
// valid appeal id
$this->Sut->redirectUrl = false;
$this->Sut->params['named']['appeal_id'] = $this->gpiAppealId;
$this->Sut->add();
$this->false($this->Sut->redirectUrl);
// setting appeal id allowed only at step 1 if different from session office id
$this->Sut->redirectUrl = false;
$this->Sut->params['named']['appeal_id'] = $this->gpiAppealId;
$this->Sut->add();
$this->false($this->Sut->redirectUrl);
$this->Sut->params['named']['appeal_id'] = $this->exampleAppealId;
$this->Sut->add(2);
$this->is($this->Sut->redirectUrl, '/');
$this->Sut->redirectUrl = false;
$this->Sut->params['named']['appeal_id'] = $this->gpiAppealId;
$this->Sut->add();
$this->false($this->Sut->redirectUrl);
$this->Sut->params['named']['appeal_id'] = $this->gpiAppealId;
$this->Sut->add(2);
$this->false($this->Sut->redirectUrl);
}
开发者ID:stripthis,项目名称:donate,代码行数:38,代码来源:gifts_controller.test.php
示例20: formatElement
/**
* Format XML for single DC element.
* @param $propertyName string
* @param $value array
* @param $multilingual boolean optional
*/
function formatElement($propertyName, $values, $multilingual = false)
{
if (!is_array($values)) {
$values = array($values);
}
// Translate the property name to XML syntax.
$openingElement = str_replace(array('[@', ']'), array(' ', ''), $propertyName);
$closingElement = String::regexp_replace('/\\[@.*/', '', $propertyName);
// Create the actual XML entry.
$response = '';
foreach ($values as $key => $value) {
if ($multilingual) {
$key = str_replace('_', '-', $key);
assert(is_array($value));
foreach ($value as $subValue) {
if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) {
$response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
} else {
$response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
}
}
} else {
assert(is_scalar($value));
$response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "</{$closingElement}>\n";
}
}
return $response;
}
开发者ID:doana,项目名称:pkp-lib,代码行数:34,代码来源:PKPOAIMetadataFormat_DC.inc.php
注:本文中的String类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论