为什么小弟我的var_dump($file_suffix=="php")总是false?明明值一样的啊
为什么我的var_dump($file_suffix=="php")总是false?明明值一样的啊.
我是想读取压缩包里面的php文件内容,结果遇到这个怪问题给困惑啊
var_dump($file_suffix=="php");明明值一样,怎么是false啊...
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->//获取后缀函数 function suffix($filename){ $string= strrpos($filename,'.'); $suffix = substr($filename,$string+1); return $suffix; } $zip = zip_open("test.zip"); //打开 ZIP 文件 if ($zip) { while ($zip_entry = zip_read($zip)) { //读取 ZIP 文件中的下一个项目 echo "Name: " . $file_name=zip_entry_name($zip_entry) . "<br>"; //返回 ZIP 文件中的一个项目的名称 echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "<br>"; //返回 ZIP 文件中的一个项目的实际文件尺寸 echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "<br>"; //返回 ZIP 文件中的一个项目的被压缩尺寸 echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "<br>"; //返回 ZIP 文件中的一个项目的压缩方法 echo $file_suffix=suffix($file_name); var_dump($file_suffix=="php"); if($file_suffix=='php'){ zip_entry_open($zip, $zip_entry, "r"); //打开 ZIP 文件中的一个项目以供读取 echo "File Contents:" . "<br>"; $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); //读取 ZIP 文件中的一个打开的项目 echo "$buf"; zip_entry_close($zip_entry); //关闭 ZIP 文件中的一个项目 } echo "<br>"; } zip_close($zip); //关闭 ZIP 文件 }
------解决方案--------------------
能一样吗?
echo "Name: " . $file_name=zip_entry_name($zip_entry) . "
"; //返回 ZIP 文件中的一个项目的名称
中 $file_name=zip_entry_name($zip_entry) . "
" 这不是后面还有
吗?
在 echo 中赋值的话,应写作
echo "Name: " .( $file_name=zip_entry_name($zip_entry) ). "
";
或
echo "Name: " , $file_name=zip_entry_name($zip_entry) , "
";

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Compressing HTML files into ZIP can improve page loading speed. Methods include: using online tools (such as FileOptimizer, TinyPNG) using command line tools (such as gzip, 7-zip) using Node.js scripts (using the zlib module)

The zip command is a very useful compression tool in Linux systems. By using the zip command, you can easily compress files and directories into a zip file and save storage space and facilitate transfer. The basic syntax of the zip command is "zip [options] [compressed file name] [file or directory to be compressed]".

In today's era of rapid technological development, programming languages are springing up like mushrooms after a rain. One of the languages that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

1. The compressed folder is a zip file [root@cgls]#zip-rmydata.zipmydata2. Unzip mydata.zip into the mydatabak directory [root@cgls]#unzipmydata.zip-dmydatabak3.mydata01 folder and mydata02.txt are compressed into mydata.zip[root@cgls]#zipmydata.zipmydata01mydata02.txt4. Decompress the mydata.zip file directly [root@cgls]#unzipmydata.zip5. View myd

7z and zip are both lossless compressions. 7z is a mainstream and efficient compression format with a very high compression ratio; the ZIP file format is a file format for data compression and document storage. 7z has a higher compression ratio, followed by zip; the zip format is more common and has a wide range of technologies, and the windows operating system supports the zip format by default.

With the development of the Internet and the advancement of information technology, the era of big data has arrived, and fields such as data analysis and machine learning have also been widely used. In these fields, task scheduling is an inevitable problem. How to achieve efficient task scheduling is crucial to improving efficiency. In this article, we will introduce how to use Golang's web framework Echo framework to implement distributed task scheduling. 1. Introduction to the Echo framework Echo is a high-performance, scalable, lightweight GoWeb framework. It is based on HTTP

Compressing files is a common operation that can save disk space and network transmission time, and Java provides the Zip function for file compression. This article will show how to use the Zip function in Java for file compression through a detailed introduction and example demonstration. 1. Introduction to the Zip function The Zip function is a compression and packaging tool library provided in Java. This function can be used to compress files or folders into a Zip format file. ZipOutputStr is mainly used in the Zip function
