本文整理汇总了PHP中nl_langinfo函数的典型用法代码示例。如果您正苦于以下问题:PHP nl_langinfo函数的具体用法?PHP nl_langinfo怎么用?PHP nl_langinfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nl_langinfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: locale_to_unicode
function locale_to_unicode($s)
{
global $encoding;
$locale_encoding = nl_langinfo(CODESET);
$s = iconv($locale_encoding, $encoding, $s);
return $s;
}
示例2: __construct
public function __construct($useLocale = false)
{
$pattern = '^y(eah?|ep|es)?$';
if ($useLocale && defined('YESEXPR')) {
$pattern = nl_langinfo(YESEXPR);
}
parent::__construct('/' . $pattern . '/i');
}
示例3: __construct
public function __construct($useLocale = false)
{
$pattern = '^n(o(t|pe)?|ix|ay)?$';
if ($useLocale && defined('NOEXPR')) {
$pattern = nl_langinfo(NOEXPR);
}
parent::__construct('/' . $pattern . '/i');
}
示例4: sanitize_latlng
/**
* Sanitize Lat/Lng
* Ensures the latitude or longitude is a floating number and that the decimal
* point is a full stop rather than a comma created by floatval() in some locales.
*
* @param number $n Latitude or Longitude.
* @return number
*/
function sanitize_latlng($n)
{
$n = floatval($n);
if (defined('DECIMAL_POINT')) {
$pt = nl_langinfo(DECIMAL_POINT);
$n = str_replace($pt, '.', $n);
}
return $n;
}
示例5: testShouldUseLocalPatternForNoExpressionWhenDefined
public function testShouldUseLocalPatternForNoExpressionWhenDefined()
{
if (!defined('NOEXPR')) {
$this->markTestSkipped('Constant NOEXPR is not defined');
return;
}
$rule = new No(true);
$actualPattern = $rule->regex;
$expectedPattern = '/' . nl_langinfo(NOEXPR) . '/i';
$this->assertEquals($expectedPattern, $actualPattern);
}
示例6: set_locale
function set_locale($lang, $charset = '')
{
$supported = array('en_US' => array('ISO-8859-1'), 'fr_FR' => array('ISO-8859-1'), 'ko_KR' => array('EUC-KR', 'UHC'));
if ($lang == 'auto') {
# get broswer's settings
$langs = get_locales();
$lang = $langs[0];
$charset = strtoupper($charset);
# XXX
$server_charset = '';
if (function_exists('nl_langinfo')) {
$server_charset = nl_langinfo(CODESET);
}
if ($charset == 'UTF-8') {
if ($charset != $server_charset) {
$lang .= "." . $charset;
}
} else {
if ($supported[$lang] && in_array($charset, $supported[$lang])) {
return $lang . '.' . $charset;
} else {
return 'en_US';
// default
}
}
}
return $lang;
}
示例7: var_dump
var_dump(convert_uudecode("+22!L;W9E(%!(4\"\$`\n`"));
var_dump(convert_uuencode("test\ntext text\r\n"));
var_dump(str_rot13("PHP 4.3.0"));
var_dump(crc32("The quick brown fox jumped over the lazy dog."));
var_dump(strlen(crypt("mypassword")));
var_dump(md5("apple"));
var_dump(sha1("apple"));
$trans = array("hello" => "hi", "hi" => "hello");
var_dump(strtr("hi all, I said hello", $trans));
var_dump(convert_cyr_string("abc", "a", "d"));
// sanity
var_dump(hebrev("test"));
// sanity
var_dump(hebrevc("test"));
// sanity
var_dump(nl_langinfo(AM_STR));
var_dump(sprintf("A%sB%dC", "test", 10));
var_dump(sprintf("%010s", "1101"));
var_dump(sprintf("%02d", "09"));
var_dump(sprintf("(%s-%s)", "foobar", "barfoo"));
var_dump(sprintf("[%s]", "ab"));
var_dump(vsprintf("A%sB%dC", array("test", 10)));
var_dump(sscanf("SN/2350001", "SN/%d"));
var_dump(sscanf("SN/2350001", "SN/%d", $out));
var_dump($out);
var_dump(chr(92));
var_dump(ord("\\"));
var_dump(money_format("%i", 1234.56));
var_dump(number_format(1234.56));
var_dump(strcmp("a", "b"));
var_dump(strcmp("a", "A"));
示例8: function_exists
}
echo "in " . $trace["file"] . " ";
echo "on line " . $trace["line"] . "<br />";
}
//endforeach
if ($exit) {
exit;
}
}
//endif
//for windows servers, we have no define time constants and nl_langinfo function
//in a limited fashion; some windows servers still show that the function
//exists even though it's not implemented, thus the second check;
$nl_exists = function_exists("nl_langinfo");
if ($nl_exists) {
$nl_exists = @nl_langinfo(CODESET);
}
if (!$nl_exists) {
function nl_langinfo($constant)
{
return $constant;
}
//end function
function nl_setup()
{
$date = mktime(0, 0, 0, 10, 7, 2007);
for ($i = 1; $i <= 7; $i++) {
define("ABDAY_" . $i, date("D", $date));
define("DAY_" . $i, date("l"), $date);
$date = strtotime("tomorrow", $date);
}
示例9: setlocale
$original = setlocale(LC_ALL, 'C');
//get an unset variable
$unset_var = 'string_val';
unset($unset_var);
//defining a class
class sample
{
public function __toString()
{
return "sample object";
}
}
//getting the resource
$file_handle = fopen(__FILE__, "r");
// array with different values for $input
$items = array(2147483647, -2147483648, -20, array(), array(0), array(1, 2), new sample(), $file_handle);
//defining '$input' argument
$input = "Test string";
// loop through with each element of the $items array to test nl_langinfo() function
$count = 1;
foreach ($items as $item) {
echo "-- Iteration {$count} --\n";
var_dump(nl_langinfo($item));
$count++;
}
fclose($file_handle);
//closing the file handle
setlocale(LC_ALL, $original);
?>
===DONE===
示例10: _showEvents
function _showEvents()
{
foreach ($this->vEvents as $event) {
?>
BEGIN:VEVENT
CREATED:<?php
echo $event["creationdate"] . "\n";
?>
LAST-MODIFIED:<?php
echo $event["modifieddate"] . "\n";
?>
DTSTAMP:<?php
echo $event["creationdate"] . "\n";
?>
UID:
<?php
echo "BB-" . $event["id"] . "\n";
?>
SUMMARY:<?php
echo $event["subject"] . "\n";
?>
DTSTART:<?php
echo $this->_toCalDate($event["startdate"]);
if ($event["starttime"]) {
echo "T" . $this->_toCalTime($event["starttime"]) . "\n";
} else {
echo "T000000" . "\n";
}
?>
DTEND:<?php
echo $this->_toCalDate($event["enddate"]);
if ($event["starttime"]) {
echo "T" . $this->_toCalTime($event["endtime"]) . "\n";
} else {
echo "T000000" . "\n";
}
if ($event["location"]) {
echo "LOCATION:" . $event["location"] . "\n";
}
if ($event["content"]) {
echo "DESCRIPTION:" . str_replace("\n", "", $event["content"]) . "\n";
}
if ($event["repeating"]) {
$rrule = "RRULE:FREQ=" . strtoupper($event["repeattype"]) . ";INTERVAL=" . $event["repeatevery"] . ";";
switch ($event["repeattype"]) {
case "Weekly":
$rrule .= "BYDAY=";
$bydayArray = explode("::", $event["repeateachlist"]);
foreach ($bydayArray as $day) {
$tempday = $day != 7 ? $day + 1 : 1;
$rrule .= strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ", ";
}
$rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
break;
case "Monthly":
if ($event["repeateachlist"]) {
$rrule .= "BYMONTHDAY=";
$bydayArray = explode("::", $event["repeateachlist"]);
foreach ($bydayArray as $day) {
$rrule .= $day . ", ";
}
$rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
} else {
if ($event["repeatontheweek"] == 5) {
$event["repeatontheweek"] = -1;
}
$tempday = $event["repeatontheday"] != 7 ? $event["repeatontheday"] + 1 : 1;
$rrule .= "BYDAY=" . $event["repeatontheweek"] . strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ";";
}
//end if
break;
case "Yearly":
$rrule .= "BYMONTH=";
$bymonthArray = explode("::", $event["repeateachlist"]);
foreach ($bymonthArray as $month) {
$rrule .= $month . ", ";
}
$rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
if ($event["repeatontheday"]) {
if ($event["repeatontheweek"] == 5) {
$event["repeatontheweek"] = -1;
}
$tempday = $event["repeatontheday"] != 7 ? $event["repeatontheday"] + 1 : 1;
$rrule .= "BYDAY=" . $event["repeatontheweek"] . strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ";";
}
//endif
break;
}
//endcase
if ($event["repeattimes"]) {
$rrule .= "COUNT=" . $event["repeattimes"] . ";";
} elseif ($event["repeatuntil"]) {
$rrule = "UNTIL=" . $this->_toCalDate($event["repeatuntil"]) . "T000000;";
}
echo substr($rrule, 0, strlen($rrule) - 1) . "\n";
}
//endif repeating
?>
END:VEVENT
<?php
//.........这里部分代码省略.........
示例11: inputBasiclist
$theinput2 = new inputBasiclist("yearlyontheweek", $therecord["repeatontheweek"], $thetable->weekArray, "on the week of", false);
if (!$therecord["repeatontheday"]) {
$theinput->setAttribute("disabled", "disabled");
$theinput2->setAttribute("disabled", "disabled");
$weekNumber = ceil(date("d", $repeatBase) / 7);
if ($weekNumber > 4) {
$weekNumber = 5;
}
$theinput->value = $weekNumber;
$theinput2->value = $weekNumber;
}
$theform->addField($theinput);
$theform->addField($theinput2);
$temparray = array();
for ($i = 1; $i < 8; $i++) {
$temparray[nl_langinfo(constant("DAY_" . $i))] = $i == 1 ? 7 : $i - 1;
}
$theinput = new inputBasiclist("monthlyontheday", $therecord["repeatontheday"], $temparray, "on the day", false);
$theinput2 = new inputBasiclist("yearlyontheday", $therecord["repeatontheday"], $temparray, "on the day", false);
if (!$therecord["repeatontheday"]) {
$theinput->setAttribute("disabled", "disabled");
$theinput2->setAttribute("disabled", "disabled");
$theinput->value = @strftime("%u", $repeatBase);
$theinput2->value = @strftime("%u", $repeatBase);
}
$theform->addField($theinput);
$theform->addField($theinput2);
$temparray = array("never" => "never", "after" => "after", "on date" => "on date");
$thevalue = "never";
if ($therecord["id"]) {
if ($therecord["repeattimes"]) {
示例12: nl_langinfo
/**
* @param $item
* @return string
* @desc 返回指定的本地信息。
*/
public static function nl_langinfo($item)
{
return nl_langinfo($item);
}
示例13: foreach
// $text .= "<tr><td colspan='2'>Data notionally deleted {$keep_month}-{$keep_year}</td></tr>";
$text .= "<tr><td>" . ADSTAT_L77 . "</td><td>";
foreach ($delete_list as $k => $v) {
$sql->db_Delete('logstats', "log_id='{$k}'");
$text .= $v . "<br />";
$logStr .= "[!br!]{$k} => " . $v;
}
$text .= "</td></tr>";
e107::getLog()->add('STAT_04', ADSTAT_L83 . $logStr, '');
}
$text .= "<tr><td>" . ADSTAT_L70 . "</td>";
$text .= "<td><select class='tbox' name='delete_month'>\n";
$match_month = date("n");
for ($i = 1; $i < 13; $i++) {
$selected = $match_month == $i ? " selected='selected'" : "";
$text .= "<option value='{$i}'{$selected}>" . nl_langinfo(constant('MON_' . $i)) . "</option>\n";
}
$text .= "</select>\n ";
$this_year = date("Y");
$text .= "<select class='tbox' name='delete_year' id='export_year'>\n";
for ($i = $this_year; $i > $this_year - 6; $i--) {
$selected = $this_year - 2 == $i ? " selected='selected'" : "";
$text .= "<option value='{$i}'{$selected}>{$i}</option>\n";
}
$text .= "</select>\n</td></tr>";
}
$text .= "</table>\r\n\t\r\n\t<div class='buttons-bar center'>\r\n\t" . $frm->admin_button('delete_history', LAN_DELETE, 'delete') . "\r\n\t</div>\r\n\t\r\n\t</form>";
$ns->tablerender(ADSTAT_L69, $mes->render() . $text);
break;
// case 'history'
}
示例14: formatBytesOrBits
/**
* Converts the value provided into a formatted string specifying the value
* in the desired multiples of bytes or bits.
*
* To force a specific prefix to be returned, and because they vary depending
* on whether SI units are used or not, the $prefix parameter must be one of
* the following values: '', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'.
*
* @param bool $bytes Whether to format as bytes or bits.
* @param mixed $n The value to format.
* @param bool $si Whether to output SI units.
* @param int $dp How many decimal places to output.
* @param string $prefix Force a prefix, e.g. 'K', 'M' (null = automatic)
* @param bool $symbol Whether to output symbols or names of unit.
*
* @return string The formatted byte value.
*/
protected static function formatBytesOrBits($bytes, $n, $si = false, $dp = 0, $prefix = null, $symbol = true)
{
$s = '';
$exponent = null;
# Parse the value provided first.
$n = $bytes ? Number::parseBytes($n) : Number::parseBits($n);
# Check decimal place is valid.
$dp = min(max(0, $dp), ini_get('precision'));
# Get unit prefix list.
$prefixes = $si ? $symbol ? Number::$SI_PREFIX_SYMBOL : Number::$SI_PREFIX_NAME : ($symbol ? Number::$IEC_PREFIX_SYMBOL : Number::$IEC_PREFIX_NAME);
# Get unit postfix.
$postfix = $bytes ? $symbol ? 'B' : 'byte' : ($symbol ? 'b' : 'bit');
# Determine whether to automatically determine the prefix.
if (!is_null($prefix)) {
$exponent = array_search(strtoupper($prefix), array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'));
if ($exponent === false) {
$exponent = null;
# Invalid, so just automatically choose.
}
}
# Calculate the correct numeric value.
$base = $si ? 1000 : 1024;
if (!is_null($exponent)) {
$n /= pow($base, $exponent);
} else {
$exponent = 0;
while ($n >= $base && $exponent < count($prefixes) - 1) {
$n /= $base;
$exponent++;
}
}
# Generate string.
$n = number_format($n, $dp, nl_langinfo(RADIXCHAR), nl_langinfo(THOUSEP));
$s = sprintf('%s %s', $n, $prefixes[$exponent] . $postfix);
if (!$symbol) {
$s = self::pluralize($s);
}
return $s;
}
示例15: nl_langinfo
<?php
/* Prototype : string nl_langinfo ( int $item )
* Description: Query language and locale information
* Source code: ext/standard/string.c
*/
echo "*** Testing nl_langinfo() : error conditions ***\n";
echo "\n-- Testing nl_langinfo() function with no arguments --\n";
var_dump(nl_langinfo());
echo "\n-- Testing nl_langinfo() function with more than expected no. of arguments --\n";
$extra_arg = 10;
var_dump(nl_langinfo(ABDAY_2, $extra_arg));
?>
===DONE===