1024programmer PHP Brother, why is my var_dump($file_suffix==”php”) always false? The values ​​are obviously the same.

Brother, why is my var_dump($file_suffix==”php”) always false? The values ​​are obviously the same.

Why is my var_dump($file_suffix==”php”) always false? The values ​​are obviously the same.
I wanted to read the contents of the php file in the compressed package, but I encountered this strange problem and was confused
var_dump($file_suffix==”php”); The values ​​are obviously the same, why is it false…

PHP code

 //Get suffix function
 function suffix($filename){
     $string= strrpos($filename,'.');
     $suffix = substr($filename,$string+1);
     return $suffix;
 }
 $zip = zip_open("test.zip"); //Open ZIP file
 if ($zip) {
     while ($zip_entry = zip_read($zip)) { //Read the next item in the ZIP file
         echo "Name: " . $file_name=zip_entry_name($zip_entry) . "
"; //Return the name of an item in the ZIP file echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "
"; //Return the actual file size of an item in the ZIP file echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "
"; //Return the compressed size of an item in the ZIP file echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "
"; //Return the compression method of an item in the ZIP file echo $file_suffix=suffix($file_name); var_dump($file_suffix=="php"); if($file_suffix=='php'){ zip_entry_open($zip, $zip_entry, "r"); //Open an item in the ZIP file for reading echo "File Contents:" . "
"; $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); //Read an open item in the ZIP file echo "$buf"; zip_entry_close($zip_entry); //Close an item in the ZIP file } echo "
"; } zip_close($zip); //Close the ZIP file }

——Solution—————— —
Can it be the same?
echo “Name: ” . $file_name=zip_entry_name($zip_entry) . “
“; //Return the name of an item in the ZIP file
$file_name=zip_entry_name($zip_entry) . “
” Isn’t there
behind this?
If you assign a value in echo, it should be written as
echo “Name: ” .( $file_name=zip_entry_name($zip_entry) ). “
“;
or
echo “Name: ” , $file_name=zip_entry_name($zip_entry) , “
“;

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/brother-why-is-my-var_dumpfile_suffixphp-always-false-the-values-are-obviously-the-same/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索