首页 > Windows开发 > 详细

Delphi通过Get获取来自PHP的返回值

时间:2017-01-20 20:26:27      阅读:168      评论:0      收藏:0      [点我收藏+]

Delphi代码

 

unit Unit1;

  

interface

  

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,

  IdTCPClient, IdHTTP;

  

type

  TForm1 = class(TForm)

    Button1: TButton;

    IdHTTP1: TIdHTTP;

    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

  

var

  Form1: TForm1;

  

implementation

{$R *.dfm}

  

procedure TForm1.Button1Click(Sender: TObject);

var

 

  idHttp1: TIdHTTP;

  stream: TStringStream;

 

begin

 

 stream := TStringStream.Create(‘‘);

 idHttp1 := TIdHTTP.Create(nil);

 

  try

 

  idHttp1.Get(‘http://localhost/DelphiRequest/index2.php‘, stream);

  Memo1.Lines.Add(UTF8Decode(stream.DataString));

 

  finally

  idHttp1.Free;

  stream.Free;

 

end;

end;

end.

//////////////////////////////////////////////////////////////////////////////////////
PHP代码

 

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/12/16 0016
 * Time: 下午 3:00
 */
function test(){
     $P="中文字符";
    if(empty($_GET)){
        
        return $P;
    }else{
        return "cuowu";
    }
}
echo test();
 
 

 

http://blog.csdn.net/s371795639/article/details/53706620

Delphi通过Get获取来自PHP的返回值

原文:http://www.cnblogs.com/findumars/p/6323712.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!