Copy the code The code is as follows:
// Create an index pointing to the new COM component
$word = new COM("word.application") or die("Can't start Word !”);
// Display the version number of Word currently being used
//echo “Loading Word, v. {$word->Version}
”;
// Set its visibility to 0 (false), if you want to open the application in the front, use 1 (true)
// to open the application in the forefront, use 1 (true)
//$word->Visible = 0;
// Open a document
$word->Documents->OPen(”d:mywebmuban.doc”);
//Read the document content
$test= $word->ActiveDocument->content->Text ;
echo $test;
echo “
”;
//Replace the variables that need to be replaced in the document
$test=str_replace("<{variable}>","This is a variable",$ test);
echo $test;
$word->Documents->Add();
// Add text to a new document
$word->Selection->TypeText("$test");
//Save the document in the directory
$word->Documents[1]->SaveAs(”d:/myweb/comtest.doc”);
// Close the connection with the COM component
$word- >Quit();
?>
The above introduces the code for reading and writing WORD documents in PHP for the simplified Chinese version of word2003, including the content of the simplified Chinese version of word2003. I hope it will be helpful to friends who are interested in PHP tutorials.