ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*
https://github.com/PHPOffice/PHPWord
https://github.com/PHPOffice/PHPWord/tree/develop/samples
https://buildmedia.readthedocs.org/media/pdf/phpword/latest/phpword.pdf
https://support.microsoft.com/en-us/office/create-forms-that-users-complete-or-print-in-word-040c5cc1-e309-445b-94ac-542f732c8c8b
ติดตั้งด้วยคำสั่ง C:\> composer require phpoffice/phpword
http://marcuscode.com/lang/php/namespaces
https://github.com/PHPOffice/PHPWord/issues/902
https://hotexamples.com/examples/-/PhpOffice%255CPhpWord%255CTemplateProcessor/getVariables/php-phpoffice%255cphpword%255ctemplateprocessor-getvariables-method-examples.html
https://thaiall.com/phpoffice/blankfield.php
*/
require_once 'vendor/autoload.php';
include_once 'phpoffice/PhpWord/PhpWord.php';
include_once 'phpoffice/PhpWord/TemplateProcessor.php';
use TemplateProcessor, Shared\Html, PhpWord;
$getfile1 = new \PhpOffice\PhpWord\TemplateProcessor('blankfield1.docx');
var_dump($getfile1->getVariables());
$getfile2 = new \PhpOffice\PhpWord\TemplateProcessor('blankfield2.docx');
var_dump($getfile2->getVariables());
$getfile3 = new \PhpOffice\PhpWord\TemplateProcessor('blankfield3.docx');
var_dump($getfile3->getVariables());
$getvar = $getfile1->getVariables();
echo 'Number of Variables: ' .count($getvar). '
';
for($i=0; $i<count($getvar); $i++) {
echo 'varname [' .$i. ']: ' .$getvar[$i]. '
';
}