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(... )".
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!