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) , “
“;