Home Backend Development PHP Tutorial php乱码有关问题

php乱码有关问题

Jun 13, 2016 am 10:11 AM
cmd gbk quot text

php乱码问题
用php通过cmd命令执行了一个应用程序text.exe,本来应该显示“执行成功”,但是在cmd中能正常显示,在浏览器中却是乱码。php文件中meta标签已规定charset是utf-8,浏览器的字符编码也是utf-8.但要是把浏览器的字符编码改为GBK的话,“执行成功”这四个字倒是能正常显示,可是页面上的其他中文字符就成乱码了。该怎么处理呢?

------解决方案--------------------
文件编码也修改成utf-8格式.直接echo ('执行成功');
------解决方案--------------------
//说明你数据库中的是gbk编码的
数据库编码要与文件编码,浏览器编码一致就不会乱码了
现在可以在 mysql查询语句前加下这句 mysql_query("set names utf8")
------解决方案--------------------
如果‘执行成功’是取回的字符串而不是在脚本中自定义的字符串,那么用iconv转一下编码试试。
------解决方案--------------------
在文件最顶端输入:
header("Content-Type:text/html;charset=utf-8");
------解决方案--------------------
ob_start();
cmd命令执行了一个应用程序text.exe
$s = ob_get_clean();
echo iconv('gbk', 'utf-8', $s);

------解决方案--------------------
cmd好像默认就是用gbk编码的。 跟你的utf-8矛盾了。所以才会乱码。

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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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)

Hot Topics

PHP Tutorial
1596
276
How to view all IP addresses in LAN using cmd How to view all IP addresses in LAN using cmd Feb 20, 2023 pm 02:22 PM

How to view all IP addresses on the LAN using cmd: 1. Press the "Win+R" shortcut key to open the "Run" window; 2. After entering "CMD" in the "Run" window, press the Enter key; 3. In the open "Command" In the "Prompt" interface, enter the command "arp -a" and press the Enter key; 4. From the returned results, you can see the IP addresses of all computers in the local LAN that communicate with the machine.

How to get BitLocker recovery key from CMD without Microsoft account How to get BitLocker recovery key from CMD without Microsoft account Feb 19, 2024 pm 09:00 PM

This guide will explain how to obtain a BitLocker recovery key to restore access to encrypted data if necessary. BitLocker is a security feature of Windows devices used to protect data from unauthorized access. Recovery keys are a backup method if you can't access your data through regular means. You can obtain a 48-digit BitLocker recovery key without a Microsoft account or via CMD, ensuring you are always able to access and recover your important data. How to get BitLocker recovery key from CMD without Microsoft account? Follow these suggestions to obtain a BitLocker recovery key: Using Command Prompt click Start, search for cmd and click to manage

CMD close port command CMD close port command Nov 21, 2023 am 09:45 AM

The command to use CMD to close a port: 1. Use CMD to close a specific port; 2. Use CMD to close all open ports; 3. Use CMD to open a specific port; 4. Use CMD to open all open ports.

Open Task Manager using command line: Detailed steps Open Task Manager using command line: Detailed steps Dec 29, 2023 pm 10:59 PM

Many friends encounter certain software getting stuck when using their computers. If the computer cannot move, you need to call up the task manager to end the process. So how to use cmd to open the task manager command? Just enter tasksmgr and press enter. The specific solutions are discussed below. Take a look. Steps to use cmd to open the Task Manager command: 1. Press and hold the Win+R keys on the keyboard to open the run window, or click "Start - Run" in the lower left corner, enter cmd in the run window, and press the Enter key to open the cmd window. 2. Enter: C:\Windows\system32\taskmgr.exe, and then press the Enter key to open the task manager. 3. Open CMD

How to turn off Bitlocker encryption using CMD at the command prompt How to turn off Bitlocker encryption using CMD at the command prompt Jun 19, 2024 am 11:33 AM

Enter the following command in the administrator command prompt to turn off manage-bde-offC: But sometimes the following prompt appears: Error - This volume stores one or more external keys that can automatically unlock other volumes. This type of key must first be deleted before this volume can be unlocked. At this time, you need to execute the following command first: (If the system partition is not C, change the drive letter below) manage-bde-autounlock-ClearAllKeysc: Error 2: This operation cannot be performed because the volume is locked. manage-bde-unlockc:-rp123456789012345678901234567890123456789012345678 Note:

What is the difference between powershell and cmd What is the difference between powershell and cmd Jan 11, 2023 pm 02:23 PM

Differences: 1. When running Cmd, it only takes up less than 1M of memory; when using PowerShell, it takes up about 20M of memory. 2. Cmd does not support syntax highlighting, but PowerShell does. 3. When using Cmd to run some more complex and time-consuming commands, when you drag the command line window at will, the content in the window can still remain the same; but PowerShell cannot. 4. Cmd can only use commands in the .net library, nor can it use Linux commands; PowerShell can.

What to do if cmd php is garbled? What to do if cmd php is garbled? Nov 22, 2022 am 10:29 AM

Solution to cmd php garbled characters: 1. In cmd or shellpower on the Windows platform, execute the php script and check whether it is garbled; 2. Modify the current page number characters by executing the "exec("CHCP 65001");" command in the php script Just set.

The difference between powershell and cmd The difference between powershell and cmd Jul 25, 2023 am 11:29 AM

The difference between powershell and cmd is: 1. Different syntax and commands. CMD uses command syntax based on MS-DOS, while Powershell uses more powerful syntax based on the .NET framework; 2. Different script support, Powershell has powerful script support, and CMD supports simple scripts; 3. Different object orientation. Powershell is based on the object-oriented programming model, while CMD is not object-oriented; 4. Different scalability; 5. Different output formats; 6. Different cross-platform support systems.

See all articles