Home > Backend Development > PHP Tutorial > acronisdiskdirector10 10 Tips for PHP Scripts 6

acronisdiskdirector10 10 Tips for PHP Scripts 6

WBOY
Release: 2016-07-29 08:33:21
Original
983 people have browsed it

PHP and COM
If you are an adventurous person and you are running PHP on a Windows system using the CGI, ISAPI or Apache module version, then you can also get the COM functionality of the system. Now, the job of explaining COM (Microsoft's Component Object Model) is left to Microsoft and those big books. However, there's nothing wrong with knowing a little bit about COM, and here's a common (no pun intended, very common) little snippet of code.
This small snippet of code uses PHP to launch Microsoft Word in the background, open a new file, type some text, save the file and then close the application:
// create a reference to a new COM component (Word)
$ word = new COM("word.application") or die("Can't start Word!");
// print the version of Word that's now in use
echo "Loading Word, v. {$word-> Version}
";
// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
$word->Visible = 0;
/ / create a new document in Word
$word->Documents->Add();
// add text to the new document
$word->Selection->TypeText("Testing 1-2-3. ..");
//save the document in the Windows temp directory
$word->Documents[1]->SaveAs("/Windows/temp/comtest.doc");
// close the connection to the COM component
$word->Quit();
// print another message to the screen
echo "Check for the file...";
?>
Assume you are running an intranet website, the The site stores data in a Microsoft SQL Server database, and your users need the data in Excel format. Then, you can have PHP perform the necessary SQL queries and format the output results, then use COM to launch Excel, transfer the data to it, and finally store the file on the user's desktop system.

The above introduces the 10 tips 6 of acronisdiskdirector10 PHP script, including the content of acronisdiskdirector10. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template