本文整理匯總了PHP中Utilities::getExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utilities::getExtension方法的具體用法?PHP Utilities::getExtension怎麽用?PHP Utilities::getExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Utilities
的用法示例。
在下文中一共展示了Utilities::getExtension方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFileExtensions
public function testFileExtensions()
{
$this->assertEquals('html', Utilities::getFileExtension('/some/dir/test.html'));
$this->assertEquals('html', Utilities::getFileExtension('test.html'));
$this->assertEquals('html', Utilities::getFileExtension('.html'));
$this->assertEquals('html', Utilities::getFileExtension('html'));
$this->assertEquals('php', Utilities::getFileExtension('test.html.php'));
$exts = array('htm' => array('text/html', 'html'), 'css' => array('text/css', 'css'), 'html' => array('text/html', 'html'), 'js' => array('application/javascript', 'js'), 'json' => array('application/json', 'json'), 'rss' => array('application/rss+xml', 'rss'), 'atom' => array('application/atom+xml', 'atom'), 'xhtml' => array('application/xhtml+xml', 'xhtml'), 'xml' => array('application/xml', 'xml'), 'jpg' => array('image/jpeg', 'jpeg'), 'gif' => array('image/gif', 'gif'), 'jpeg' => array('image/jpeg', 'jpeg'), 'png' => array('image/png', 'png'), 'txt' => array('text/plain', 'txt'), 'unknown' => array('text/plain', 'txt'));
foreach ($exts as $ext => $a) {
list($mime, $ext2) = $a;
$actualMime = Utilities::getContentType($ext);
$this->assertEquals($mime, $actualMime);
$this->assertEquals($ext2, Utilities::getExtension($actualMime));
}
$this->assertEquals(null, Utilities::getExtension('text/unknown'));
}
示例2: loadHelpers
function loadHelpers($type)
{
if ($type === 'all') {
$files = scandir($this->quantum_root . 'system/helpers/');
//var_dump($files);
foreach ($files as $file) {
if (Utilities::getExtension($file) == 'php') {
include_once $this->quantum_root . 'system/helpers/' . $file;
}
}
return true;
} else {
$file = $type;
include_once $this->quantum_root . 'app/helpers/' . $file;
return true;
}
}