News

Hello World

  • 09 / 02 / 2009


This information is outdated, please, refer to the PHPDocX tutorial for up to date info.
PHPDOCX could not be less than other web applications so we are proud to introduce you to the “Hello World Script” that will allow you to generate, yes you guessed it right, an absurdly boring Word document with a simple “Hello World” on it.

As you can see the process is simple and a few lines of code will do, assuming you have already installed the PHPDOCX library on your web server.



The code read as follows:


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx();
$objDocx->fAddText('Hello World.');
$objDocx->fCreateDocx('hello_world.docx');




But if you are a sophisticated programmer you may try the same document with advanced formatting


You may center the text and write it in bold characters with one line more of code:


require_once('../classes/cCreateDocx.inc');
$objDocx = new cCreateDocx(); $arrParamsText = array( 'b' => 'single', 'jc' => 'center’); //b for bold and jc for alignment
$objDocx->fAddText('Hello World.', $arrParamsText);
$objDocx->fCreateDocx('hello_world.docx');




You may not get a job as a designer with the generated document but we hope it will tempt you to scan our support documentation to learn what else can be done with PHPDOCX .