为什么小弟我的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

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

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



Use Java's File.length() function to get the size of a file. File size is a very common requirement when dealing with file operations. Java provides a very convenient way to get the size of a file, that is, using the length() method of the File class. . This article will introduce how to use this method to get the size of a file and give corresponding code examples. First, we need to create a File object to represent the file we want to get the size of. Here is how to create a File object: Filef

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

How to convert php blob to file: 1. Create a php sample file; 2. Through "function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} ” method can be used to convert Blob to File.

Use Java's File.renameTo() function to rename files. In Java programming, we often need to rename files. Java provides the File class to handle file operations, and its renameTo() function can easily rename files. This article will introduce how to use Java's File.renameTo() function to rename files and provide corresponding code examples. The File.renameTo() function is a method of the File class.

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

Use java's File.getParent() function to get the parent path of a file. In Java programming, we often need to operate files and folders. Sometimes, we need to get the parent path of a file, which is the path of the folder where the file is located. Java's File class provides the getParent() method to obtain the parent path of a file or folder. The File class is Java's abstract representation of files and folders. It provides a series of methods for operating files and folders. Among them, get

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
