本文整理汇总了PHP中String类的典型用法代码示例。如果您正苦于以下问题:PHP String类的具体用法?PHP String怎么用?PHP String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例3: testNoMatch
function testNoMatch()
{
$input = new String("blaat");
$pattern = "|<[^>]+>(.*)</[^>]+>|U";
$matches = $input->getMatches($pattern);
$this->assertEqual(0, $matches->size());
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
示例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()));
}
示例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");
}
示例12: funname
public function funname()
{
import('@.ORG.String');
/**
* 生成随机名称
*/
$str = new String();
$name = $str->uuid();
$name = str_replace("}", "", $name);
$name = str_replace("{", "", $name);
return $name;
}
示例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();
}
示例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);
}
示例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;
}