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

  • 相关阅读:
    JAR 归档文件是与平台无关的文件格式
    事件的监听是由awt完成的
    AWT和Swing之间的基本区别
    Swing AWT一套新的图形界面系统
    AWT控件称为重量级控件
    java做web项目比较多
    Swing文本域的编辑
    AWT中文译为抽象窗口工具包
    swing包含了各种组件的类
    Java中的Swing及AWT又称GUI编程
  • 原文地址:https://www.cnblogs.com/findumars/p/6323712.html
Copyright © 2011-2022 走看看