本文整理匯總了PHP中Inflector::ascii方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::ascii方法的具體用法?PHP Inflector::ascii怎麽用?PHP Inflector::ascii使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::ascii方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_base64_encode_image
public function action_base64_encode_image()
{
if ($_POST) {
$asciiFormat = Inflector::ascii(Input::post('filename'));
$webSafeName = Inflector::friendly_title($asciiFormat, '_', true);
$uploadLocation = 'assets/img/upload/';
$config = array('auto_process' => 'false', 'path' => DOCROOT . $uploadLocation, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'), 'new_name' => $webSafeName, 'normalize' => true, 'change_case' => 'lower', 'auto_rename' => false, 'overwrite' => true);
// process the uploaded files in $_FILES
Upload::process($config);
// if there are any valid files
if (Upload::is_valid()) {
// save them according to the config
Upload::save();
// Grab the file extension
$uploadedFile = Upload::get_files(0);
$filename = $webSafeName . '.' . $uploadedFile['extension'];
$input_file = $uploadedFile['saved_to'] . $uploadedFile['saved_as'];
$image64Encoded = $this->_base64_encode_image($input_file, $uploadedFile['extension']);
$asset = Model_Asset::forge(array('name' => $uploadedFile['saved_as'], 'uri' => $uploadLocation, 'type' => $uploadedFile['extension']));
$asset->save();
return '<img src="' . $image64Encoded . '" />';
} else {
// and process any errors
foreach (Upload::get_errors() as $key => $file) {
// $file is an array with all file information,
// $file['errors'] contains an array of all error occurred
// each array element is an an array containing 'error' and 'message'
// Session::set_flash('error', $file['errors'] );
echo 'Error ' . $key . ' - ';
print_r($file['errors']);
echo ' <br />';
}
die;
}
}
return;
}
示例2: test_ascii
/**
* Test for Inflector::ascii()
*
* @test
*/
public function test_ascii()
{
$output = Inflector::ascii('Inglés');
$expected = "Ingles";
$this->assertEquals($expected, $output);
}