本文整理汇总了PHP中UTF8::strtoupper方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::strtoupper方法的具体用法?PHP UTF8::strtoupper怎么用?PHP UTF8::strtoupper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::strtoupper方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _ucfirst
/**
* UTF8::ucfirst
*
* @package Kohana
* @author Kohana Team
* @copyright (c) 2007-2012 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ucfirst($str)
{
if (UTF8::is_ascii($str)) {
return ucfirst($str);
}
preg_match('/^(.?)(.*)$/us', $str, $matches);
return UTF8::strtoupper($matches[1]) . $matches[2];
}
示例2: _ucwords
/**
* UTF8::ucwords
*
* @package JsonApiApplication
* @author JsonApiApplication Team
* @copyright (c) 2007-2012 JsonApiApplication Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ucwords($str)
{
if (UTF8::is_ascii($str)) {
return ucwords($str);
}
// [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
// This corresponds to the definition of a 'word' defined at http://php.net/ucwords
return preg_replace_callback('/(?<=^|[\\x0c\\x09\\x0b\\x0a\\x0d\\x20])[^\\x0c\\x09\\x0b\\x0a\\x0d\\x20]/u', function ($matches) {
return UTF8::strtoupper($matches[0]);
}, $str);
}
示例3: generate_challenge
/**
* Generates a new Captcha challenge.
*
* @return string The challenge answer
*/
public function generate_challenge()
{
// Load words from the current language and randomize them
$words = Config::get('captcha', 'words');
shuffle($words);
// Loop over each word...
foreach ($words as $word) {
// ...until we find one of the desired length
if (abs(Captcha::$config['complexity'] - UTF8::strlen($word)) < 2) {
return UTF8::strtoupper($word);
}
}
// Return any random word as final fallback
return UTF8::strtoupper($words[array_rand($words)]);
}
示例4: action_zhuz
public function action_zhuz()
{
$zhuz_type = $this->request->param('id', 'old');
switch ($zhuz_type) {
case 'old':
$id = 6;
break;
case 'mid':
$id = 3;
break;
case 'jr':
$id = 4;
break;
}
$all = ORM::factory('Zhuze')->where('parent_id', '=', $id)->order_by('name_' . strtolower(I18n::lang()))->find_all();
$words = array();
if (count($all) > 0) {
$letter = 'А';
foreach ($all as $one) {
if (UTF8::strtoupper(UTF8::substr($one->name, 0, 1)) != $letter) {
$letter = UTF8::strtoupper(UTF8::substr($one->name, 0, 1));
}
$words[$letter][] = array('letter' => UTF8::strtoupper(UTF8::substr($one->name, 0, 1)), 'word' => $one->name, 'id' => $one->id_publication);
}
}
//var_dump($words);
$this->add_cumb(i18n::get('Шежире – древо единства казахов'), 'shezhire');
if ($zhuz_type == 'old') {
$this->add_cumb(i18n::get('Старший жуз'), '');
} elseif ($zhuz_type == 'mid') {
$this->add_cumb(i18n::get('Средний жуз'), '');
} else {
$this->add_cumb(i18n::get('Младший жуз'), '');
}
$this->set('nomer', 0);
$this->set('zhuz', $zhuz_type);
$this->set('words', $words);
}
示例5: test_strtoupper
/**
* Tests UTF8::strtoupper
*
* @test
* @dataProvider provider_strtoupper
*/
public function test_strtoupper($input, $expected)
{
$this->assertSame($expected, UTF8::strtoupper($input));
UTF8::$server_utf8 = !UTF8::$server_utf8;
$this->assertSame($expected, UTF8::strtoupper($input));
UTF8::$server_utf8 = !UTF8::$server_utf8;
}
示例6: action_editbook
public function action_editbook()
{
//die('lol');
$id = (int) $this->request->param('id', 0);
$book = ORM::factory('Book', $id);
$selected = (int) Arr::get($_GET, 'category', 0);
$this->set('selected', $selected);
$this->set('book', $book);
$cats = ORM::factory('Library_Category')->fulltree;
$this->set('cats', $cats);
$uploader = View::factory('storage/pdf')->set('user_id', $this->user->id)->render();
$this->set('uploader', $uploader);
$pdf = $book->pdf;
if ($pdf->loaded()) {
$this->set('pdf', $pdf);
} else {
$this->set('pdf', FALSE);
}
if ($this->request->method() == 'POST') {
$type = Security::xss_clean(Arr::get($_POST, 'type', ''));
$language = Security::xss_clean(Arr::get($_POST, 'language', ''));
$subject = Security::xss_clean(Arr::get($_POST, 'subject', ''));
$class = Security::xss_clean(Arr::get($_POST, 'class', ''));
$title = Security::xss_clean(Arr::get($_POST, 'title', ''));
$storage_id = (int) Arr::get($_POST, 'storage_id', 0);
$cover_id = (int) Arr::get($_POST, 'cover_id', 0);
$description = Security::xss_clean(Arr::get($_POST, 'description', ''));
$category_id = (int) Arr::get($_POST, 'category_id', 0);
$published = (int) Arr::get($_POST, 'published', 0);
$letter = UTF8::strtoupper(UTF8::substr($title, 0, 1));
$author = Security::xss_clean(Arr::get($_POST, 'author', ''));
$publisher = Security::xss_clean(Arr::get($_POST, 'publisher', ''));
$year = (int) Arr::get($_POST, 'year', 0);
$RandomNum = time();
$i = 0;
// $post = $this->request->post();
// $post['date'] = date('Y-m-d H:i:s',strtotime($post['date']));
//$date = $post['date'];
$message = "";
try {
$book->file_path = $RandomNum;
$book->kol = $i;
$book->type = $type;
$book->language = $language;
$book->subject = $subject;
$book->class = $class;
$book->title = $title;
$book->storage_id = $storage_id;
$book->cover_id = $cover_id;
$book->description = $description;
$book->category_id = $category_id;
$book->published = $published;
$book->author = $author;
$book->year = $year;
$book->publisher = $publisher;
$book->letter = $letter;
$book->save();
if ($_FILES) {
$output_dir = "media/upload/" . $RandomNum . "/";
mkdir($output_dir, 0777);
if (isset($_FILES["myfile"])) {
$ImageName = str_replace(' ', '-', strtolower($_FILES['myfile']['name']));
$ImageType = $_FILES['myfile']['type'];
//"image/png", image/jpeg etc.
$ImageExt = substr($ImageName, strrpos($ImageName, '.'));
$ImageExt = str_replace('.', '', $ImageExt);
if ($ImageExt != "pdf") {
$message = "Invalid file format only <b>\"PDF\"</b> allowed.";
} else {
$ImageName = preg_replace("/\\.[^.\\s]{3,4}\$/", "", $ImageName);
$NewImageName = $RandomNum . '.' . $ImageExt;
move_uploaded_file($_FILES["myfile"]["tmp_name"], $output_dir . $NewImageName);
$location = "convert -density 200";
$name = $output_dir . $NewImageName;
$pdftext = file_get_contents($name);
$num = preg_match_all("/\\/Page\\W/", $pdftext, $dummy);
for ($i = 0; $i < $num; ++$i) {
$nameto = $output_dir . $RandomNum . "-" . $i . ".png";
$convert = $location . " " . $name . "[" . $i . "]" . " " . "-append -resize 850" . $nameto;
exec($convert);
}
$dir = opendir($output_dir);
$i = 0;
while (false !== ($file = readdir($dir))) {
if (strpos($file, '.png', 1)) {
$i++;
}
}
}
}
}
$event = $id ? 'edit' : 'create';
$loger = new Loger($event, $book->title);
$loger->log($book);
$this->set('RandomNum', $RandomNum);
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors($e->alias());
$this->set('errors', $errors);
}
}
//.........这里部分代码省略.........
示例7: test_strtoupper
/**
* Tests UTF8::strtoupper
*
* @test
* @dataProvider provider_strtoupper
*/
public function test_strtoupper($input, $expected)
{
$this->assertSame($expected, UTF8::strtoupper($input));
}
示例8: _ucwords_callback
function _ucwords_callback($matches)
{
return UTF8::strtoupper($matches[0]);
}
示例9: update_response_session
/**
* Update captcha response session variable.
*
* @return void
*/
public function update_response_session()
{
// Store the correct Captcha response in a session
Session::instance()->set('captcha_response', sha1(UTF8::strtoupper($this->response)));
}
示例10: valid
/**
* Validates user's Captcha response and updates response counter.
*
* @staticvar integer $counted Captcha attempts counter
* @param string $response User's captcha response
* @return boolean
*/
public static function valid($response)
{
// Maximum one count per page load
static $counted;
// User has been promoted, always TRUE and don't count anymore
if (Captcha::instance()->promoted()) {
return TRUE;
}
// Challenge result
$result = (bool) (sha1(UTF8::strtoupper($response)) === Session::instance()->get('captcha_response'));
// Increment response counter
if ($counted !== TRUE) {
$counted = TRUE;
// Valid response
if ($result === TRUE) {
Captcha::instance()->valid_count(Session::instance()->get('captcha_valid_count') + 1);
} else {
Captcha::instance()->invalid_count(Session::instance()->get('captcha_invalid_count') + 1);
}
}
return $result;
}
示例11: Load
private function Load()
{
$buf = "";
$buf .= "/******************************************************************************\n";
$buf .= "* Class for " . $this->table . "." . $this->table_descriptor->getTable() . "\n";
$buf .= "*******************************************************************************/\n\n";
$table_name = UTF8::strtoupper(UTF8::substr($this->table_descriptor->getTable(), 0, 1)) . UTF8::substr($this->table_descriptor->getTable(), 1, UTF8::strlen($this->table_descriptor->getTable()) - 1);
$buf .= "class Entity_{$table_name}\n{\n";
foreach ($this->table_descriptor->getColumns() as $column) {
$column_name = str_replace('-', '_', $column['column_name']);
$buf .= "\t/**\n";
$buf .= "\t* @var {$this->variable_types[$column['type']]}\n";
if ($column['column_name'] == $this->table_descriptor->getPrimaryKey()) {
$buf .= "\t* Class Unique ID\n";
}
//$buf .= "\t* Class Unique ID\n";
$buf .= "\t* comment\t\"" . $column['comment'] . "\"\n";
$buf .= "\t*/\n";
$buf .= "\tpublic \${$column_name};\n\n";
// if ( UTF8::strpos($column['column_name'], '_id') !=FALSE )
// {
// $related_table_name=UTF8::substr($column['column_name'], 0, UTF8::strlen($column['column_name'])-3)."_list";
// $buf .= "\t/**\n";
// $buf .= "\t* comment\t\"".$column['comment']."\"\n";
// $buf .= "\t*/\n";
// $buf .= "\tprivate $related_table_name=array()\n\n";
//
// $buf .= "\tpublic function get_$related_table_name())\n";
// $buf .= "\t{\n";
// $buf .= "\t\t return \$this->$related_table_name\n";
// $buf .= "\t}\n\n";
//
// $buf .= "\tpublic function set_$related_table_name(\$$related_table_name))\n";
// $buf .= "\t{\n";
// $buf .= "\t\t \$this->$related_table_name=\$$related_table_name\n";
// $buf .= "\t}\n\n";
// }
}
$relations = Kohana::config('cb_relations.relations');
foreach ($relations as $relation) {
$child_table_name = $relation['child_table'];
if ($relation['parent_table'] == $this->table_descriptor->getTable()) {
$buf .= "\t/**\n";
$buf .= "\t* object related to table \t\"" . $child_table_name . "\"\n";
$buf .= "\t*/\n";
$buf .= "\tprivate \${$child_table_name}=array();\n\n";
$buf .= "\tpublic function get_{$child_table_name}(\$filter=NULL)\n";
$buf .= "\t{\n";
$buf .= "\t\t if ( \$filter != NULL AND count(\$this->{$child_table_name})>0 ) return {$child_table_name};\n";
$buf .= "\t\t \$sql=\"select id from {$child_table_name}\";\n";
$buf .= "\t\t\t\$first_filter=TRUE;\n";
$buf .= "\t\t\tif ( \$filter != NULL )\n";
$buf .= "\t\t\t{\n";
$buf .= "\t\t\t\tforeach (array_keys(\$filter) as \$key)\n";
$buf .= "\t\t\t\t{\n";
$buf .= "\t\t\t\tif ( ! empty( \$filter[\$key] ) )\n";
$buf .= "\t\t\t\t{\n";
$buf .= "\t\t\t\t\tif ( \$first_filter == TRUE )\n";
$buf .= "\t\t\t\t\t{\n";
$buf .= "\t\t\t\t\t\t\$sql .= ' where '.\$key.' '.\$filter[\$key];\n";
$buf .= "\t\t\t\t\t\t\$first_filter = false;\n";
$buf .= "\t\t\t\t\t}else\n";
$buf .= "\t\t\t\t\t{\n";
$buf .= "\t\t\t\t\t\t\$sql .= ' AND '.\$key.' '.\$filter[\$key];\n";
$buf .= "\t\t\t\t\t}\n";
$buf .= "\t\t\t\t}\n";
$buf .= "\t\t\t\t}\n";
$buf .= "\t\t\t}\n\n";
$buf .= "\t\t\$result = Database::instance()->query(Database::SELECT, \$sql, FALSE);\n";
$buf .= "\t\tforeach (\$result as \${$child_table_name})\n";
$buf .= "\t\t{\n";
$buf .= "\t\t\t\$this->{$child_table_name}" . '[]' . " = new Entity_{$table_name}(\$" . $child_table_name . "['id']);\n";
$buf .= "\t\t}\n";
$buf .= "\t\treturn \$this->{$child_table_name};\n";
$buf .= "\t}\n\n";
$buf .= "\tpublic function set_{$child_table_name}(\${$child_table_name})\n";
$buf .= "\t{\n";
$buf .= "\t\t \$this->{$child_table_name}=\${$child_table_name};\n";
$buf .= "\t}\n\n";
}
}
//правила проверки модели
$rules = array();
foreach ($this->table_descriptor->getColumns() as $column) {
$column_rule = array();
if ($column['column_name'] != $this->table_descriptor->getPrimaryKey()) {
$column_rule['type'] = $column['type'];
$column_rule['is_nullable'] = $column['is_nullable'];
if ($column['type'] == 'string') {
$column_rule['character_maximum_length'] = $column['character_maximum_length'];
}
$rules[$column['column_name']] = $column_rule;
}
}
$buf .= "\t/**\n";
$buf .= "\t*\tПравила для проверки модели\n";
$buf .= "\t*/\n";
$buf .= "\tpublic \$rules=array(\n";
foreach ($rules as $name => $rule) {
$buf .= "\t\t'" . $name . "'=>array(";
//.........这里部分代码省略.........