Home >Backend Development >PHP Problem >What should I do if php reads garbled words?

What should I do if php reads garbled words?

藏色散人
藏色散人Original
2021-10-26 10:20:082388browse

Solution to php reading garbled word: 1. Open the corresponding PHP code file; 2. Call the word component through com, with code such as "new COM( "word.application ") or die(... )".

What should I do if php reads garbled words?

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

What should I do if php reads garbled words?

How does PHP handle garbled characters when reading a word document?

The PHP file is UTF-8. After reading it out, the original style of Word must be maintained.

Method:

Call the word component through com and try it.

<?
// this script is come from zend. :)
$word = new COM( "word.application ") or die( "Unable to instanciate Word ");
print "Loaded Word, version {$word-> Version}\n ";
$word-> Visible = 1;
$word-> Documents-> Add();
$word-> Selection-> TypeText( "This is a test... ");
$word-> Documents[1]-> SaveAs( "Useless test.doc ");
$word-> Quit();
?>

Note: This will not work after office07

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if php reads garbled words?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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