Hello World

  • Sep 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:

$objDocx = new cCreateDocx();
$objDocx->fAddText('Hello World.');

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:

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

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 .