How to View a Word Document From PHPby Jim Campbell
Word documents are rich-text documents that allow you to create newsletters, contracts and other customer communication. You can display these Word documents in the user's browser using the PHP programming language. The PHP programming language provides developers with a free resource to create dynamic webpages. You can create dynamic content by displaying a Word document for the web reader.
Create your Word application and file name variable. These variables are required to point PHP to the file and use the internal Word functions. The following code creates the variables: $app= new COM("Word.Application"); $file = "/worddoc.doc";
Open the Word document and set its attribute to visible. The following code opens the Word document: $app->visible = true; $app->Documents->Open($file);
Print out the Word document to the web browser. The following code prints the Word document to the browser, so your readers can view the file: $app->ActiveDocument->PrintOut();
Close the document and quit the application. The Word document still displays in the user's browser, but the memory resources are freed on the server. The following code closes your document: $app->ActiveDocument->Close(); $app->Quit();
- computer image by blaine stiger from Fotolia.com