试着检查是否"pdf"是一个字符串


Trying to check if "pdf" is in a string

我试图检查字符串的最后3个字母是否为PDF,但它不起作用,这是我的代码到目前为止希望有人能帮助

$CV = $_POST["CV"];
$lengthCV =strlen($CV);
if(strpos("$CV","pdf",substr('$CV',$lengthCV - 3)) !== false){ 
    echo "your file is a pdf";
}
else{
    echo "you didnt upload a pdf file";
    die();  
}

使用此代码;完美的工作:

                $CV = trim($_POST["CV"]);    
                $FnameArr = explode('.',$CV);
                $ext = end($FnameArr);
                if(strtolower($ext)!='pdf'){
                    // YOUR CODE GOES HERE.
                }
                else{
                    echo "you didnt upload a pdf file";
                    die();  
                }