当前位置: 首页>>代码示例>>PHP>>正文


PHP URLify::downcode方法代码示例

本文整理汇总了PHP中URLify::downcode方法的典型用法代码示例。如果您正苦于以下问题:PHP URLify::downcode方法的具体用法?PHP URLify::downcode怎么用?PHP URLify::downcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在URLify的用法示例。


在下文中一共展示了URLify::downcode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: asciify

 /** Takes text and converts it to an ASCII-only string (characters with code between 32 and 127, plus \t, \n and \r).
  * @param string $text The text to be converted.
  * @param string $locale='' The locale for the string. If not specified we consider the current locale.
  * @return string
  */
 public function asciify($text, $locale = '')
 {
     if (!strlen($locale)) {
         $locale = \Localization::activeLocale();
     }
     $language = substr($locale, 0, strcspn($locale, '_'));
     $text = \URLify::downcode($text, $language);
     if (preg_match('/[^\\t\\r\\n\\x20-\\x7e]/', $text)) {
         if (function_exists('iconv')) {
             $t = @iconv(APP_CHARSET, 'US-ASCII//IGNORE//TRANSLIT', $text);
             if (is_string($t)) {
                 $text = $t;
             }
         }
         $text = preg_replace('/[^\\t\\r\\n\\x20-\\x7e]/', '', $text);
     }
     return $text;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:23,代码来源:Text.php

示例2: safeString

/**
 * Returns a "safe" version of the given string - basically only US-ASCII and
 * numbers. Needed because filenames and titles and such, can't use all characters.
 *
 * @param string $str
 * @param boolean $strict
 * @param string $extrachars
 * @return string
 */
function safeString($str, $strict = false, $extrachars = "")
{
    $str = URLify::downcode($str);
    $str = str_replace("&", "", $str);
    $delim = '/';
    if ($extrachars != "") {
        $extrachars = preg_quote($extrachars, $delim);
    }
    if ($strict) {
        $str = strtolower(str_replace(" ", "-", $str));
        $regex = "[^a-zA-Z0-9_" . $extrachars . "-]";
    } else {
        $regex = "[^a-zA-Z0-9 _.," . $extrachars . "-]";
    }
    $str = preg_replace($delim . $regex . $delim, '', $str);
    return $str;
}
开发者ID:LeonB,项目名称:site,代码行数:26,代码来源:lib.php

示例3: remove_accent

function remove_accent($str)
{
    return URLify::downcode($str);
}
开发者ID:austinvernsonger,项目名称:htmly,代码行数:4,代码来源:admin.php

示例4: test_many_rounds_with_unknown_language_code

 function test_many_rounds_with_unknown_language_code()
 {
     for ($i = 0; $i < 1000; $i++) {
         URLify::downcode('Lo siento, no hablo español.', -1);
     }
 }
开发者ID:baardev,项目名称:lbtb,代码行数:6,代码来源:URLifyTest.php

示例5: dirname

<?php

//Downcode the provided argument or stdin if the argument was not present
require_once dirname(__DIR__) . '/URLify.php';
//Print usage and exit if arguments are invalid
if ($argc < 1 || $argc > 2) {
    die("Usage (argument): php " . basename(__FILE__) . " \"<text to downcode>\"\nUsage (pipe): <Arbitrary command> | php " . basename(__FILE__) . "\n");
}
//Process the provided argument
if ($argc === 2) {
    $s = $argv[1];
    //Or read from stdin if the argument wasn't present
} else {
    $piped = true;
    $s = file_get_contents("php://stdin");
}
echo URLify::downcode($s) . ($piped ? "\n" : "");
开发者ID:MartinStefani,项目名称:urlify,代码行数:17,代码来源:downcode.php

示例6: test_add_chars

 function test_add_chars()
 {
     $this->assertEquals('¿ ® ¼ ¼ ¾ ¶', URLify::downcode('¿ ® ¼ ¼ ¾ ¶'));
     URLify::add_chars(array('¿' => '?', '®' => '(r)', '¼' => '1/4', '¼' => '1/2', '¾' => '3/4', '¶' => 'P'));
     $this->assertEquals('? (r) 1/2 1/2 3/4 P', URLify::downcode('¿ ® ¼ ¼ ¾ ¶'));
 }
开发者ID:nathanieltite,项目名称:elefant,代码行数:6,代码来源:URLifyTest.php

示例7: post_edit_marker

 public function post_edit_marker($id)
 {
     $input = Input::all();
     $file = Input::file('img_input');
     $rules = array('name' => 'required|max:150', 'address' => 'required|max:200', 'lat' => 'required|numeric', 'lng' => 'required|numeric', 'type' => 'required|alpha', 'img_input' => 'mimes:jpg,gif,png,jpeg|image');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         return Redirect::to_action('home@edit_marker/' . $id)->with_errors($v);
     } else {
         // save thumbnail
         if (!empty($file['name'])) {
             $success = Resizer::open($file)->resize(120, 100, 'landscape')->save('public/img/uploads/' . $file['name'], 90);
         }
         URLify::add_chars(array('á' => '&aacute;', 'à' => '&agrave;', 'ä' => '&auml;', 'Á' => '&Aacute;', 'À' => '&Agrave;', 'â' => '&acirc;', 'Â' => '&Acirc;', 'ã' => '&atilde;', 'Ã' => '&Atilde;', 'Ä' => '&Auml;', 'Ç' => '&Ccedil;', 'ç' => '&ccedil;', 'é' => '&eacute;', 'É' => '&Eacute;', 'è' => '&egrave;', 'È' => '&Egrave;', 'ê' => '&ecirc;', 'Ê' => '&Ecirc;', 'ë' => '&euml;', 'Ë' => '&Euml;', 'ü' => '&uuml;', 'Ü' => '&Uuml;', 'û' => '&ucirc;', 'Û' => '&Ucirc;', 'ú' => '&uacute;', 'Ú' => '&Uacute;', 'ù' => '&ugrave;', 'Ù' => '&Ugrave;', 'ó' => '&oacute;', 'Ó' => '&Oacute;', 'ò' => '&ograve;', 'Ò' => '&Ograve;', 'ô' => '&ocirc;', 'Ô' => '&Ocirc;', 'ö' => '&ouml;', 'Ö' => '&Ouml;', 'ß' => '&szlig;', 'ÿ' => '&yuml;'));
         $marker = Marker::where('id', '=', $id)->first();
         $marker->name = URLify::downcode($input['name']);
         $marker->address = URLify::downcode($input['address']);
         $marker->lat = $input['lat'];
         $marker->lng = $input['lng'];
         $marker->type = $input['type'];
         $marker->user_id = Auth::user()->group == 2 ? Auth::user()->id : $input['client'];
         $marker->rem1 = URLify::downcode(Input::get('rem1', ''));
         $marker->rem2 = URLify::downcode(Input::get('rem2', ''));
         $marker->rem3 = URLify::downcode(Input::get('rem3', ''));
         $marker->rem4 = URLify::downcode(Input::get('rem4', ''));
         $marker->rem5 = URLify::downcode(Input::get('rem5', ''));
         if (!empty($file['name'])) {
             $marker->img_url = '/img/uploads/' . $file['name'];
         }
         $marker->save();
         return Redirect::to_action('home@edit_marker/' . $id)->with('message', 'Marker updated!');
     }
 }
开发者ID:nWidart,项目名称:Alys-Google-Maps-Organiser,代码行数:33,代码来源:home.php


注:本文中的URLify::downcode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。