Search code examples
c#php.netutf-8

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


How to create simplest (less lines of code, less strange words) PHP Get API (so any program 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 - concatenate two 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());
        return result;
    }

Solution

  • Dunno if I'm missing something, but:

    <?php
    
    function concatinateStrigs($a, $b){
        return $a . $b;
    }
    
    echo concatinateStrigs($_GET['astring'], $_GET['bstring']);
    
    ?>