本文整理汇总了PHP中capitalize函数的典型用法代码示例。如果您正苦于以下问题:PHP capitalize函数的具体用法?PHP capitalize怎么用?PHP capitalize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了capitalize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: capitalize_words
public static function capitalize_words($str, $join = '')
{
$spl = preg_split('/[^A-Za-z0-9]/', $str);
$res = array();
foreach ($spl as $part) {
$res[] = capitalize($part);
}
return join($join, $res);
}
示例2: check_http
<?php
/*
* Module: process_styles_edit.inc.php
* Description: This module does all the heavy lifting for adding/editing info in the "sponsors" table
*/
if (isset($_SESSION['loginUsername']) && $_SESSION['userLevel'] <= 1) {
$sponsorURL = check_http($_POST['sponsorURL']);
$sponsor_name = capitalize($_POST['sponsorName']);
if (NHC) {
// Place NHC SQL calls below
} else {
if ($action == "update") {
foreach ($_POST['id'] as $id) {
if ($_POST['sponsorEnable' . $id] == 1) {
$enable = 1;
} else {
$enable = 0;
}
$updateSQL = sprintf("UPDATE %s SET sponsorEnable='%s' WHERE id='%s'", $sponsors_db_table, $enable, $id);
mysql_real_escape_string($updateSQL);
$result1 = mysql_query($updateSQL, $brewing) or die(mysql_error());
}
$massUpdateGoTo = $base_url . "index.php?section=admin&go=sponsors&msg=9";
$pattern = array('\'', '"');
$massUpdateGoTo = str_replace($pattern, "", $massUpdateGoTo);
header(sprintf("Location: %s", stripslashes($massUpdateGoTo)));
}
if ($action == "add") {
$insertSQL = sprintf("INSERT INTO {$sponsors_db_table} (sponsorName, sponsorURL, sponsorImage, sponsorText, sponsorLocation, sponsorLevel, sponsorEnable) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($sponsor_name, "text"), GetSQLValueString($sponsorURL, "text"), GetSQLValueString($_POST['sponsorImage'], "text"), GetSQLValueString($_POST['sponsorText'], "text"), GetSQLValueString($_POST['sponsorLocation'], "text"), GetSQLValueString($_POST['sponsorLevel'], "int"), GetSQLValueString($_POST['sponsorEnable'], "int"));
mysql_select_db($database, $brewing);
示例3: GetSQLValueString
$updateSQL .= "brewFG=" . GetSQLValueString($_POST['brewFG'], "text") . ", ";
$updateSQL .= "brewPrimary=" . GetSQLValueString($_POST['brewPrimary'], "text") . ", ";
$updateSQL .= "brewPrimaryTemp=" . GetSQLValueString($_POST['brewPrimaryTemp'], "text") . ", ";
$updateSQL .= "brewSecondary=" . GetSQLValueString($_POST['brewSecondary'], "text") . ", ";
$updateSQL .= "brewSecondaryTemp=" . GetSQLValueString($_POST['brewSecondaryTemp'], "text") . ", ";
$updateSQL .= "brewOther=" . GetSQLValueString($_POST['brewOther'], "text") . ", ";
$updateSQL .= "brewOtherTemp=" . GetSQLValueString($_POST['brewOtherTemp'], "text") . ", ";
$updateSQL .= "brewFinings=" . GetSQLValueString($_POST['brewFinings'], "text") . ", ";
$updateSQL .= "brewWaterNotes=" . GetSQLValueString($_POST['brewWaterNotes'], "text") . ", ";
$updateSQL .= "brewCarbonationMethod=" . GetSQLValueString($_POST['brewCarbonationMethod'], "text") . ", ";
$updateSQL .= "brewCarbonationVol=" . GetSQLValueString($_POST['brewCarbonationVol'], "text") . ", ";
$updateSQL .= "brewCarbonationNotes=" . GetSQLValueString($_POST['brewCarbonationNotes'], "text") . ", ";
$updateSQL .= "brewBoilHours=" . GetSQLValueString($_POST['brewBoilHours'], "text") . ", ";
$updateSQL .= "brewBoilMins=" . GetSQLValueString($_POST['brewBoilMins'], "text") . ", ";
}
$updateSQL .= "brewName=" . GetSQLValueString(capitalize($brewName), "text") . ", ";
$updateSQL .= "brewStyle=" . GetSQLValueString($row_style_name['brewStyle'], "text") . ", ";
$updateSQL .= "brewCategory=" . GetSQLValueString($styleTrim, "text") . ", ";
$updateSQL .= "brewCategorySort=" . GetSQLValueString($styleFix, "text") . ", ";
$updateSQL .= "brewSubCategory=" . GetSQLValueString($style[1], "text") . ", ";
$updateSQL .= "brewInfo=" . GetSQLValueString($brewInfo, "text") . ", ";
$updateSQL .= "brewMead1=" . GetSQLValueString($brewMead1, "text") . ", ";
$updateSQL .= "brewMead2=" . GetSQLValueString($brewMead2, "text") . ", ";
$updateSQL .= "brewMead3=" . GetSQLValueString($brewMead3, "text") . ", ";
$updateSQL .= "brewComments=" . GetSQLValueString(strip_newline($_POST['brewComments']), "text") . ", ";
$updateSQL .= "brewBrewerID=" . GetSQLValueString($brewBrewerID, "text") . ", ";
$updateSQL .= "brewBrewerFirstName=" . GetSQLValueString($brewBrewerFirstName, "text") . ", ";
$updateSQL .= "brewBrewerLastName=" . GetSQLValueString($brewBrewerLastName, "text") . ", ";
$updateSQL .= "brewJudgingLocation=" . GetSQLValueString($row_style_name['brewStyleJudgingLoc'], "text") . ", ";
$updateSQL .= "brewCoBrewer=" . GetSQLValueString(ucwords($_POST['brewCoBrewer']), "text") . ", ";
$updateSQL .= "brewUpdated=" . "NOW( ), ";
示例4: implode
$location_pref2 = implode(",", $_POST['brewerStewardLocation']);
} elseif ($_POST['brewerJudgeLocation'] != "" && !is_array($_POST['brewerStewardLocation'])) {
$location_pref2 = $_POST['brewerStewardLocation'];
}
} else {
$location_pref2 = "";
}
// Add the user's info to the "brewer" table
// Numbers 999999994 through 999999999 are reserved for NHC applications.
if ($_POST['brewerAHA'] < "999999994" || $_POST['brewerAHA'] == "") {
$insertSQL = sprintf("INSERT INTO {$brewer_db_table} (\r\n\t\t\t uid,\r\n\t\t\t brewerFirstName, \r\n\t\t\t brewerLastName, \r\n\t\t\t brewerAddress, \r\n\t\t\t brewerCity, \r\n\t\t\t brewerState, \r\n\t\t\t \r\n\t\t\t brewerZip,\r\n\t\t\t brewerCountry,\r\n\t\t\t brewerPhone1, \r\n\t\t\t brewerPhone2, \r\n\t\t\t brewerClubs, \r\n\t\t\t brewerEmail, \r\n\t\t\t \r\n\t\t\t brewerSteward, \r\n\t\t\t brewerJudge,\r\n\t\t\t brewerJudgeID,\r\n\t\t\t brewerJudgeMead,\r\n\t\t\t brewerJudgeRank,\r\n\t\t\t brewerJudgeLocation,\r\n\t\t\t brewerStewardLocation,\r\n\t\t\t brewerAHA\r\n\t\t\t) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($row_user['id'], "int"), GetSQLValueString(capitalize($_POST['brewerFirstName']), "text"), GetSQLValueString(capitalize($_POST['brewerLastName']), "text"), GetSQLValueString(capitalize($_POST['brewerAddress']), "text"), GetSQLValueString(capitalize($_POST['brewerCity']), "text"), GetSQLValueString($_POST['brewerState'], "text"), GetSQLValueString($_POST['brewerZip'], "text"), GetSQLValueString($_POST['brewerCountry'], "text"), GetSQLValueString($_POST['brewerPhone1'], "text"), GetSQLValueString($_POST['brewerPhone2'], "text"), GetSQLValueString($_POST['brewerClubs'], "text"), GetSQLValueString($username, "text"), GetSQLValueString($_POST['brewerSteward'], "text"), GetSQLValueString($_POST['brewerJudge'], "text"), GetSQLValueString($_POST['brewerJudgeID'], "text"), GetSQLValueString($_POST['brewerJudgeMead'], "text"), GetSQLValueString($_POST['brewerJudgeRank'], "text"), GetSQLValueString($location_pref1, "text"), GetSQLValueString($location_pref2, "text"), GetSQLValueString($_POST['brewerAHA'], "int"));
} else {
$insertSQL = sprintf("INSERT INTO {$brewer_db_table} (\r\n\t\t\t uid,\r\n\t\t\t brewerFirstName, \r\n\t\t\t brewerLastName, \r\n\t\t\t brewerAddress, \r\n\t\t\t brewerCity, \r\n\t\t\t brewerState, \r\n\t\t\t \r\n\t\t\t brewerZip,\r\n\t\t\t brewerCountry,\r\n\t\t\t brewerPhone1, \r\n\t\t\t brewerPhone2, \r\n\t\t\t brewerClubs, \r\n\t\t\t brewerEmail, \r\n\t\t\t \r\n\t\t\t brewerSteward, \r\n\t\t\t brewerJudge,\r\n\t\t\t brewerJudgeID,\r\n\t\t\t brewerJudgeMead,\r\n\t\t\t brewerJudgeRank,\r\n\t\t\t brewerJudgeLocation,\r\n\t\t\t brewerStewardLocation\r\n\t\t\t) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($row_user['id'], "int"), GetSQLValueString(capitalize($_POST['brewerFirstName']), "text"), GetSQLValueString(capitalize($_POST['brewerLastName']), "text"), GetSQLValueString(capitalize($_POST['brewerAddress']), "text"), GetSQLValueString(capitalize($_POST['brewerCity']), "text"), GetSQLValueString($_POST['brewerState'], "text"), GetSQLValueString($_POST['brewerZip'], "text"), GetSQLValueString($_POST['brewerCountry'], "text"), GetSQLValueString($_POST['brewerPhone1'], "text"), GetSQLValueString($_POST['brewerPhone2'], "text"), GetSQLValueString($_POST['brewerClubs'], "text"), GetSQLValueString($username, "text"), GetSQLValueString($_POST['brewerSteward'], "text"), GetSQLValueString($_POST['brewerJudge'], "text"), GetSQLValueString($_POST['brewerJudgeID'], "text"), GetSQLValueString($_POST['brewerJudgeMead'], "text"), GetSQLValueString($_POST['brewerJudgeRank'], "text"), GetSQLValueString($location_pref1, "text"), GetSQLValueString($location_pref2, "text"));
}
if (NHC) {
$updateSQL = sprintf("INSERT INTO nhcentrant (\r\n\t\t\tuid, \r\n\t\t\tfirstName, \r\n\t\t\tlastName, \r\n\t\t\temail,\r\n\t\t\tAHAnumber,\r\n\t\t\tregionPrefix\r\n\t\t\t) \r\n\t\t\tVALUES \r\n\t\t\t(%s, %s, %s, %s, %s, %s)", GetSQLValueString($row_user['id'], "int"), GetSQLValueString(capitalize($_POST['brewerFirstName']), "text"), GetSQLValueString(capitalize($_POST['brewerLastName']), "text"), GetSQLValueString($username, "text"), GetSQLValueString($_POST['brewerAHA'], "text"), GetSQLValueString($prefix, "text"));
mysql_real_escape_string($updateSQL);
$result = mysql_query($updateSQL, $brewing) or die(mysql_error());
}
//echo $insertSQL;
mysql_select_db($database, $brewing);
mysql_real_escape_string($insertSQL);
$result1 = mysql_query($insertSQL, $brewing) or die(mysql_error());
// Stop Gap for random staff assignments
$updateSQL1 = sprintf("UPDATE %s SET staff_judge='0', staff_judge_bos='0', staff_steward='0', staff_organizer='0', staff_staff='0' WHERE uid=%s", $prefix . "staff", $row_user['id']);
mysql_real_escape_string($updateSQL1);
$result1 = mysql_query($updateSQL1, $brewing) or die(mysql_error());
if ($filter == "default") {
// Log in the user and redirect
session_start();
$_SESSION['loginUsername'] = $username;
示例5: printf
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Pass by reference </title>
<meta name="description" content="Pass by reference ">
<meta name="author" content="Nermin Sehic">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
$first = 'musa';
$middle = 'cazim';
$last = 'catic';
printf('<br />NAME BEFORE: %s %s %s', $first, $middle, $last);
capitalize($first, $middle, $last);
printf('<br />NAME AFTER: %s %s %s', $first, $middle, $last);
?>
</body>
</html>
示例6: text_capitalize
function text_capitalize()
{
$this->assertEqual("Selected", capitalize("selected"));
$this->assertEqual("One two", capitalize("ONE TWO"));
$this->assertEqual("Three four", capitalize("three four"));
}
示例7: image_tag
/**
* Builds a valid \<img /\> HTML tag.
*
* @param string $source
* The source path to the image.
* @param string|array $attributes
* (optional) A single HTML attribute or an array of HTML attributes to be
* added to the rendered tag.
* @return @e string
* A valid \<img /\> HTML tag.
*
* @ingroup helperfunc
*
* @see TagHelper::content_tag()
*
*/
public function image_tag($source, $attributes = NULL)
{
if (!(is_absolute_url($source) || is_root_relative_url($source))) {
$source = image_url($source);
}
$info = pathinfo($source);
$extension = isset($info['extension']) ? $info['extension'] : '';
$options = array("src" => $this->asset_version($source), "alt" => capitalize(basename($source, '.' . $extension)));
if (is_array($attributes)) {
$options = array_merge($options, $attributes);
}
return content_tag("img", NULL, $options);
}
示例8: generateClass
function generateClass($tableName, $fields)
{
$className = capitalize($tableName);
$output = generateClassHead($className);
// Done
$output .= generateClassVars($className);
// Done
$output .= generateClassConstructor($className, $fields);
// Done
$output .= generateClassObjectCreator($tableName, $className, $fields);
// Done
$output .= generateClassFetchData($tableName, $className, $fields);
// Done
$output .= generateClassGetID($className, $fields);
// DONE
foreach ($fields as $fieldName => $field) {
$output .= generateClassGetField($className, $fieldName, $field);
// Done
}
$output .= generateClassDelete($tableName, $fields);
$output .= generateClassUpdate($tableName, $className, $fields);
// Done
$output .= generateClassBottom($className);
// Done
return $output;
}
示例9: compare_part
function compare_part($s, $i, $flags, $dist = 0)
{
global $DEBUG_STRING_PHP;
if (strpos($s, "\\") === false) {
if ($DEBUG_STRING_PHP) {
echo "Simple:<ol>";
}
if (match($i, $s, $flags, $dist) === null) {
if ($DEBUG_STRING_PHP) {
echo "</ol>False";
}
return null;
} else {
if ($DEBUG_STRING_PHP) {
echo "</ol>True ('{$s}')";
}
return $s;
}
}
if ($DEBUG_STRING_PHP) {
echo "compare part: '{$s}' and '{$i}'<ol>";
}
$opts = [];
$l = 0;
$arr = [];
$lens = strlen($s);
$capitals = [];
// Pre-scan for (first-level) curly brace expressions
while ($l < $lens) {
$j2 = $j1 = $l;
$r0 = str_between("\\{", "\\}", $s, $l);
$r1 = str_between("\\(", "\\)", $s, $j1);
$r2 = str_between("\\[", "\\]", $s, $j2);
if ($r0 === null) {
break;
}
if ($r1 and $j1 < $l) {
//if ($DEBUG_STRING_PHP) echo "Parentheses at $j1 beat $l<br>";
$l = $j1 + strlen($r1) + 4;
continue;
}
if ($r2 and $j2 < $l) {
//if ($DEBUG_STRING_PHP) echo "Brackets at $j2 beat $l<br>";
$l = $j2 + strlen($r2) + 4;
continue;
}
if ($r0 and ($r0[0] === "*" or $r0[0] === "\\" and $r0[1] === "*")) {
$capitalize = $r0[0] === "*";
$r0 = substr($r0, 1);
} else {
$capitalize = false;
}
$capitals[] = $capitalize;
$opts[] = $r0;
$arr[] = [$r0, $l];
// cache for later
$l += strlen($r0) + 4;
}
if ($DEBUG_STRING_PHP and $arr) {
var_dump($arr);
}
if ($DEBUG_STRING_PHP and $capitals) {
var_dump($capitals);
}
//if ($DEBUG_STRING_PHP and $opts) var_dump($opts);
$r = "";
$l = 0;
$backtrack = [];
$failed_backtrack = [];
$saved = NULL;
$back = function ($forwards = false) use($s, &$i, &$r, &$l, &$next, &$arr, &$opts, &$capitals, &$backtrack, &$dist, &$failed_backtrack, &$saved, $DEBUG_STRING_PHP) {
if (!$forwards and $forwards !== NULL) {
if ($saved !== NULL) {
list($i, $r, $l, $arr, $opts, $capitals, $dist) = $saved;
$saved = NULL;
return true;
}
while ($backtrack and in_array(sanitize2($backtrack[count($backtrack) - 1]), $failed_backtrack)) {
array_pop($backtrack);
}
if (!$backtrack) {
return false;
}
$failed_backtrack[] = sanitize2($backtrack[count($backtrack) - 1]);
if (count($failed_backtrack) > 6) {
return false;
}
list($i, $r, $l, $arr, $opts, $capitals, $dist) = array_pop($backtrack);
if ($DEBUG_STRING_PHP) {
$remaining = substr($s, $l);
if ($l) {
$remaining = "...{$remaining}";
}
echo "<hr style='height: 6px'>!! Backtracking to {$l} '{$remaining}' (match so far '{$r}', trying to match '{$i}') !!<hr style='height: 6px'>";
var_dump($arr);
var_dump($capitals);
var_dump($opts);
foreach ($failed_backtrack as $f) {
var_dump($f);
}
//.........这里部分代码省略.........
示例10: capitalize
<?php
function capitalize(&$str)
{
$str = strtolower($str);
$str[0] = strtoupper($str[0]);
echo $str;
}
$str = "fengjie";
capitalize($str);
echo $str;
示例11: display_word_info
function display_word_info($w, $can_edit = FALSE)
{
$id = $w->id();
$lang = $w->lang();
$spart = $w->speechpart();
$common = false;
$w->clear_connections();
$connections = $w->connections();
$w->read_paths();
$w->read_attrs();
display_lang($w);
?>
<span class="word-name" id="word<?php
echo $w->id();
?>
_name"><?php
echo display_word_name($w, $common);
?>
</span>
<?php
if ($common) {
echo format_abbr("c.", "Common Gender") . " ";
} elseif ($lang === "la" and $spart === "noun" and $genders = $w->path()->iterate("gender")) {
foreach ($genders as $g) {
echo format_abbr($g[0] . ".", capitalize($g));
}
echo " ";
}
$infos = [];
/*
$stem = $w->path();
if ($stem->hasvalue())
$infos[] = format_word(str_replace("\n", ", ", $stem->get()));
*/
$infos[] = $spart;
foreach ($w->read_attrs() as $attr) {
if ($attr->tag()[0] != "-") {
$infos[] = format_attr($attr->tag(), $attr->value());
}
}
?>
(<?php
echo implode("; ", $infos);
?>
)<?php
if ($can_edit !== NULL and $can_edit) {
$slug = slugify($w, $lang);
$class = "word{$id}_toolbox";
?>
<?php
display_icon("tools", "Tools", "word{$id}_tools", NULL, "hider hiding2");
?>
<script type="text/javascript">
$(function() {
var id = <?php
echo $id;
?>
;
var state = -1;
$('#word'+id+'_tools').on('mousedown', function(e) {
if (state === -1) {
$(this).removeClass('hiding2');
state = 0;
}
e.preventDefault();
return false;
}).on('mouseup', function(e) {
if (state === 0) state = 1;
else if (state === 1) {
$(this).addClass('hiding2');
state = -1;
}
e.preventDefault();
return false;
}).on('click', function(e){e.preventDefault();return false;});
});
</script>
<span class="<?php
echo $class;
?>
">
<?php
display_icon("hardlink", "Link by ID", NULL, "dictionary.php?id={$id}");
?>
<?php
display_icon("del", "Delete", "word{$id}_delete");
?>
<script type="text/javascript">
$(function() {
var id = <?php
echo $id;
?>
;
$('#word'+id+'_delete').on("click", function() {
dict.word_delete(id);
});
});
</script>
<?php
display_icon("rename", "Rename", "word{$id}_rename");
//.........这里部分代码省略.........
示例12: titleize
/**
* Capitalizes all the words and replaces some characters in the string to create a nicer
* looking title. {@link titleize()} is meant for creating pretty output. It is not used in
* the Rails internals.
*
* <pre>
* $this->titleize('man from the boondocks'); // "Man From The Boondocks"
* $this->titleize('x-men: the last stand'); // "X Men: The Last Stand"
* $this->titleize('TheManWithoutAPast'); // "The Man Without A Past"
* $this->titleize('raiders_of_the_lost_ark'); // "Raiders Of The Lost Ark"
* </pre>
*
* @param string $str
*
* @return string
*/
public function titleize($str)
{
$str = $this->underscore($str);
$str = $this->humanize($str);
$str = preg_replace_callback('/\\b(?<![\'’`])[a-z]/', function ($matches) {
return capitalize($matches[0]);
}, $str);
return $str;
}
示例13: foreach
$def_expr = NULL;
foreach ($word->definitions() as $def) {
if ($def->lang() !== "en") {
continue;
}
$_path = $def->path();
if ($_path and !$path->issub($_path, TRUE)) {
continue;
}
if ($def->type() === "expr") {
$def_expr = $def->value();
} else {
$defs = array_merge($defs, explode("\n", $def->value()));
}
}
$defs = array_map("trim", $defs);
if ($number === "plural") {
$defs = array_map("pluralize", $defs);
$defs = flatten($defs);
$art = "[the|some]";
} else {
$art = "[a[n]|the]";
}
if (!$def_expr) {
$def_expr = make_expr($defs);
}
$correct = [capitalize(implode(" ", [$pron[0], $be[0], "(the)", $defs[0]]))];
$expr = "{*" . implode("} {", array_map("make_expr", [$pron, $be, $art])) . " {$def_expr}}";
error_log($expr);
return ["correct" => $correct, "expr" => $expr];
}, "answer0-tooltip" => "English translation", "answer0-language" => "en"]]]]);
示例14: capitalize
<?php
include 'function_capitalize.php';
include_once 'function_capitalize.php';
$s = "fengjie";
capitalize($s);
echo $s;
示例15: titleize
/**
* Capitalizes the first letter of every word.
*
* @param string $text
* The text to be capitalized.
*
* @return string
* The text with every word capitalized.
*
* @ingroup helperfunc
*/
function titleize($text)
{
$words = explode(" ", $text);
$capitalized_words = array();
foreach ($words as $word) {
$capitalized_words[] = capitalize($word);
}
return join(" ", $capitalized_words);
}