function runCrystal($my_report, $my_pdf){
//?? Create a new COM Object of Crytal Reports XI R2??
$ObjectFactory = new COM("CrystalReports115.ObjectFactory.1");
//?? Create a instance of library Application ??-
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");//ตรงนี้คือบรรทัดที่ 14 นะครับ
//?? Open your rpt file ??
$creport = $crapp->OpenReport($my_report, 1);
//$zz= $creport->ParameterFields(1)->SetCurrentValue("Touchsharp.NET"); //send parameter example
//?? Export to PDF ??-
$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->FormatType=31;
$creport->ExportOptions->DestinationType=1;
$creport->Export(false);
//?? Release the variables
$creport = null;
$crapp = null;
$ObjectFactory = null;
}