Home Backend Development PHP Tutorial 为什么小弟我的var_dump($file_suffix=="php")总是false?明明值一样的啊

为什么小弟我的var_dump($file_suffix=="php")总是false?明明值一样的啊

Jun 13, 2016 pm 01:09 PM
echo entry name quot zip

为什么我的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 文件
}

Copy after login


------解决方案--------------------
能一样吗?
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) , "
";
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Best Guide to Compressing HTML Files to ZIP Best Guide to Compressing HTML Files to ZIP Apr 09, 2024 pm 04:09 PM

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)

Detailed explanation of decompression file command (zip) under centos7 Detailed explanation of decompression file command (zip) under centos7 Jan 07, 2024 pm 06:30 PM

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

How to use linux compression zip command How to use linux compression zip command Oct 08, 2023 pm 01:25 PM

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]".

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

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

How to use Zip function in Java for file compression How to use Zip function in Java for file compression Jun 26, 2023 pm 02:10 PM

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

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

&quot;Go Language Development Essentials: 5 Popular Framework Recommendations&quot; 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

Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Jun 13, 2023 pm 05:01 PM

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets

Detailed explanation of the role and usage of the echo keyword in PHP Detailed explanation of the role and usage of the echo keyword in PHP Jun 28, 2023 pm 08:12 PM

Detailed explanation of the role and usage of the echo keyword in PHP PHP is a widely used server-side scripting language, which is widely used in web development. The echo keyword is a method used to output content in PHP. This article will introduce in detail the function and use of the echo keyword. Function: The main function of the echo keyword is to output content to the browser. In web development, we need to dynamically present data to the front-end page. At this time, we can use the echo keyword to output the data to the page. e

See all articles