// 查找文件名,输出后缀名
function extend_end($filename){
echo substr($filename, strripos($filename, '.'));
}
extend_end('hell000o .world.html');
function extend_end($filename){
echo substr($filename, strripos($filename, '.'));
}
extend_end('hell000o .world.html');
2017-12-23
任务:
function getFileExt(string $path) :string {
return pathinfo($path)['extension'];
}
function getFileExt(string $path) :string {
return pathinfo($path)['extension'];
}
2017-12-22
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
$info = pathinfo($file);
return $info['extension'];
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return end(explode('.', $file));
}
}
echo get_extension('1234234.php.txt');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return end(explode('.', $file));
}
}
echo get_extension('1234234.php.txt');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
}
echo get_extension('1.php.html');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('get_extension')){
function get_extension($file)
{
return substr($file, strrpos($file, '.')+1);
}
}
echo get_extension('1.php.html');
?>
2017-12-20
小任务:
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('test')){
function test($fileName){
return substr(strrchr($fileName, '.'), 1);
}
}
echo test('1.php.html');
?>
<?php
header('content-type:text/html;charset=utf-8');
if(!function_exists('test')){
function test($fileName){
return substr(strrchr($fileName, '.'), 1);
}
}
echo test('1.php.html');
?>
2017-12-19
function getExpandedName($filename){
$arr=explode(".",$filename );
return $arr[sizeof($arr)-1];//得到最後一個
}
echo getExpandedName("test.php");
$arr=explode(".",$filename );
return $arr[sizeof($arr)-1];//得到最後一個
}
echo getExpandedName("test.php");
2017-12-04
function getFileName($name = '1.txt')
{
$fileName = substr($name,strripos($name,'.')) ;
return $fileName;
}
{
$fileName = substr($name,strripos($name,'.')) ;
return $fileName;
}
2017-11-29
第一个echo 是输出的调用时传入的数值,第二个echo是输出的上一个if执行完毕输出的数值,所以输出来的结果是相对着的。不错,搞懂了!
2017-11-24