image.png

php代码获取文件扩展名?php代码实现获取文件扩展名功能


php代码是嵌入在html中的


代码:

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>获取文件扩展名</title>
        <style>
            h2{text-align: center;}
            p{padding-left: 15px}
            .box{height:180px;width: 100%;border:1px soild #ccc; box-shadow: 7px 8px 7px #999;}
        </style>
    </head>
    <body>
        <div class="box">
            <?php
            //获取文件扩展名的函数,参数为文件的路径
            function getFileExt($path){
                //获取文件扩展名
                $ext = substr($path,strpos($path,'.')+1);
                //返回文件扩展名
                return $ext;
            }
            //设置路径
            $path = 'F:\html.txt';
            //调用函数getFileExt()获取文件扩展名
            $ext = getFileExt($path);
            echo '<h2>获取文件扩展名</h2>';
            echo "<p>文件路径:$path";
            //输出获取的文件扩展名
            echo "<p>文件扩展名:$ext";
            ?>
        </div>
    </body>
</html>

php代码获取文件扩展名?php代码实现获取文件扩展名功能

p79

宗波尘客www.zbck123.com宗九尘博客