开发者

How to create simpliest PHP Get API with UTF-8 support?

How to create simpliest *(less lines of code, less strange words) PHP Get API *(so any programm made in .Net C# could call url like http://localhost/api.php?astring=your_utf-8_string&bstring=your_utf-8_string ) with UTF-8 support?

What I need Is PHP API with one function - concatinate 2 strings so that a simple .net client like this would be able to use it:

    public string setStream(string astring, string bstring)
    {
string newAstring =Uri.EscapeDataString(astring);
string newBstring = Uri.EscapeDataString(bstring);
        WebClient client = new WebClient();
        var result = client.DownloadString(("http://localhost/api.php?" + string.Format("astring={0}&bstring={1}", newAstring, newBstring)).ToString());
       开发者_StackOverflow中文版 return result;
    }


public string SetStream(string astring, string bstring)
{
    using (var client = new WebClient())
    {
        var values = new NameValueCollection() {
            "astring", astring,
            "bstring", bstring
        };
        var result = client.UploadValues(
            "http://localhost/api.php", 
            "GET",
            values
        );
        return Encoding.Default.GetString(result);
    }
}


Dunno if I'm missing something, but:

<?php

function concatinateStrigs($a, $b){
    return $a . $b;
}

echo concatinateStrigs($_GET['astring'], $_GET['bstring']);

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜