How to use PHP & Word (Word.Application) - Create Word Document The Learn / Lutorial / Sctipts php programming how to using PHP Create word document (.doc)
ShotDev Focus:
- PHP & Create word document (.doc)
Example
php_create_word.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $Wrd = new COM("Word.Application"); $Wrd->Application->Visible = False; $Wrd->Documents->Add(); $DocName = "MyDoc/MyWord.doc"; //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp $Wrd->Selection->TypeText("Welcome To www.ShotDev.Com"); //$Wrd->ActiveDocument->SaveAs($strPath."/".$DocName); $Wrd->ActiveDocument->SaveAs(realpath($DocName)); $Wrd->Application->Quit; $Wrd = null; ?> Word Created <a href="<?=$DocName?>">Click here</a> to Download. </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_create_word.php
Screenshot
1strength…
…