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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

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

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

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

Which one is lossless, 7z or zip? Which one is lossless, 7z or zip? Jan 19, 2021 pm 06:37 PM

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.

Implementing distributed task scheduling using Golang's web framework Echo framework Implementing distributed task scheduling using Golang's web framework Echo framework Jun 24, 2023 am 11:49 AM

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

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

See all articles