zoukankan      html  css  js  c++  java
  • Delphi通过Get获取来自PHP的返回值

    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

  • 相关阅读:
    关于vue的npm run dev和npm run build
    移动端meta行大全
    浅谈前端三大框架Angular、react、vue
    Web Workers
    Meta(其他信息)
    页面
    页面
    日期和时间
    ECharts教程(未完)
    页面
  • 原文地址:https://www.cnblogs.com/findumars/p/6323712.html
Copyright © 2011-2022 走看看