Forum > Operating Systems
Sending strings from PHP to a freepascal lazarus executable
(1/1)
pascalbythree:
Hey! Does anybody have a URL / Example code for how to exchange strings from a PHP thread on a Raspberry to a lazarus executable ? Or a name for a component set?
Greets, Wouter van Wegen
Phil:
--- Quote from: pascalbythree on January 11, 2018, 04:13:04 pm ---Hey! Does anybody have a URL / Example code for how to exchange strings from a PHP thread on a Raspberry to a lazarus executable ? Or a name for a component set?
--- End quote ---
Maybe write a PHP extension in Pascal?
https://en.wikipedia.org/wiki/Php4delphi
Maybe supply more detail here. Why PHP? What's it used for? That sort of thing.
Leledumbo:
Depends on how they communicate each other. You can use PHP's built-in exec, Pascal executable will just receive it as normal command line parameters.
balazsszekely:
Basic communication:
1. PHP - Save as lazarus.php, copy to your local server:
--- Code: PHP [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<?php $a=$_POST['a']; $b=$_POST['b']; echo $a + $b;?>2. Lazarus - Create a new project, add a TButton, create OnClick event:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses fphttpclient; procedure TForm1.Button1Click(Sender: TObject);var FPHTTPClient: TFPHTTPClient; SL: TStringList; Str: String;begin FPHTTPClient := TFPHTTPClient.Create(nil); try FPHTTPClient.AllowRedirect := True; SL := TStringList.Create; try SL.Add('a=' + IntToStr(9)); SL.Add('b=' + IntToStr(6)); try Str := FPHTTPClient.SimpleFormPost('http://localhost/lazarus.php', SL); ShowMessage(Str); except on E: exception do ShowMessage(E.Message); end; finally SL.Free; end; finally FPHTTPClient.Free; end;end;
Navigation
[0] Message Index