- Home /
Call single function in php from c#?
Working on my Unity/php/mysql project and trying to set up what I'm going to need.
Can you call a single function in a php script from a c# script? I'd like to know if I can set up multiple functions in the php script and call them one by one as needed or only have single scripts in php to do everything. Does this make sense?
php function1()
{
code
}
php function 2()
{
more code
}
c# script
call php function1();
call php function2();
or does it need to be-
WW UserData = new WWW ("http://url.to.script/scriptname.php")
Answer by ShadyProductions · Nov 19, 2017 at 01:41 PM
For a simple GET you can do:
var webClient = new WebClient();
webClient.DownloadString("http://someurl.com/somescript.php");
You could then return perhaps an XML or JSON formatted response from the PHP script?
You can use WebClient for POST too.
On a side note, I'm sure you could achieve this using unity's WWW class too.
Thanks Shady! It's too bad you can't have one script with all the functions you need in php and simply call them as needed. It's all kinda messy.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Saving a leaderboard using PHP and C#. 2 Answers
Distribute terrain in zones 3 Answers
How to download Image from mysql and convert to texture. 1 Answer
Live chat using MySQL? 0 Answers