Линк на загрузку:Download php4delphi.7.2.zip (1.7 MB) (в комплекте идут инструкции и примеры).
Небольшая цитата из readme:
Код: Выделить всё
PHP4Delphi library
PHP - Delphi interface and PHP extensions development framework
{ $Id: readme.txt,v 7.2 10/2009 delphi32 Exp $ }
PHP4Delphi is a Delphi interface to PHP for Delphi 5, 6, 7, Delphi 2005 - Delphi 2010
PHP4Delphi consists of 3 big subprojects:
1. PHP scripting (using PHP as a scripting language in Delphi applications)
PHP4Delphi allows to execute the PHP scripts within the Delphi program using
TpsvPHP component directly without a WebServer.
It is a PHP extension that enables you to write client-side GUI applications.
One of the goals behind it was to prove that PHP is a capable general-purpose scripting
language that is suited for more than just Web applications.
It is used by "Delphi for PHP" from CodeGear.
2. PHP extensions development framework (using Delphi to extend PHP functionality)
Visual Development Framework gives possibility to create custom PHP
Extensions using Delphi.
PHP extension, in the most basic of terms, is a set of instructions that is
designed to add functionality to PHP.
3. PHP4Applications (integrate PHP in any application)
Supports C, C++, Visual Basic, VBA, C#, Delphi, Delphi .NET, Visual Basic .NET etc.
More detail information available in php4Delphi manual php4Delphi.pdfЕсли вкратце, то всё что нужно, это создать/проинициализировать пару классов, указать файл скрипта который будем выполнять (а можно просто и строку из памяти), задать/предопределить (при желании) переменные, которые будут доступны в скрипте, выполнить и забрать результат
Набросал тестовую утилитку (модифицировал один из примеров), чтобы можно было по быстрому оценить возможности.
Вот момент предопределения переменных и получение результата (собственно, соль работы с компонентом):
Код: Выделить всё
// передаём необходимые параметры в скрипт:
FPHP.Variables.Add.Name := 'url';
FPHP.Variables.ByName('url').AsString := 'http://google.com/';
FPHP.Variables.Add.Name := 'x';
FPHP.Variables.ByName('x').AsInteger := 10;
FPHP.Variables.Add.Name := 'y';
FPHP.Variables.ByName('y').AsInteger := 20;
FPHP.Variables.Add.Name := 'z';
FPHP.Variables.ByName('z').AsInteger := 5;
// выполняем
FPHP.Execute;
// забираем результат
SetLength(tmp, FBody.Size);
FBody.Read(tmp[1], FBody.Size); // тело ответа хранится в TMemoryStream
Result := FHeaders + #13#10#13#10 + tmp;Код: Выделить всё
<?php
$body = '$url = '.$base_url."\r\n".
'$x = '.$x."\r\n".
'$y = '.$y."\r\n".
'$z = '.$z."\r\n";
header("HTTP/1.1 200 OK");
header('Content-type: text/html');
header('Content-length: '.StrLen($body) );
header('Connection: Close');
print $body;
?>P.P.S. Ах да, компонент бесплатный и full source.