PHP "web service" and jQuery ajax
First I would like to say, congratulations on stepping out of the Microsoft bubble!

To begin, most PHP functions are very similar (if not exactly the same) to their linux counterparts. Some of them even just directly call their linux counterparts and return the result.  You don't have to know linux shell script to know PHP (or vice versa) but it definitely helps and knowing that there is a deeply connected relationship between the two is a enlightening.

PHP has a few global variables that you should familiarize yourself with:


$_POST: holds any POST data sent with the request
$_GET: holds any GET data sent with the request
$_SESSION: holds the session data


My first recommendation for you is to use the $_POST variable instead of using file_get_contents("php://input").  

I have to be honest, in all my years of PHP development, I've never used file_get_contents("php://input") for anything. I didn't even know what that did when I read this post. I had to look it up so that I could answer intelligently.  All the POST data will be nicely, and automatically, placed into the $_POST array for you every single time.

My second recommendation for you is to checkout the PHP function empty().  This can be used on arrays with any key, even if the key doesn't exist, to check either if the key actually exists or if the key has an empty value.  It's great for an initial check on POST data.

So for example, you could replace:

if(!property_exists($json_data, "MethodName") || is_null($json_data-&gt;MethodName) || function_exists($json_data-&gt;MethodName . "()"))


with 

if(empty($_POST['MethodName']))


Pretty neat right?

The only caveat with this function is that it will return true not only if the array index doesn't exist, but also if the value at the array index evaluates to false ("", 0, array(), null, etc...).   If you need to handle values that evaluate to false differently than you can use isset() either in addition to or instead of empty() which will tell you if the key is set, regardless of whether the value is an empty value or not.

So basically, $_POST, empty(), isset() are your bread and butter for form data processing in PHP.  Use them wisely.  :)

You should also check out unset()([http://]php.net/manual/en/function.unset.php), which lets you unset keys in your data arrays, for example, to remove keys that are set but have empty values that you'd rather just not be in the array at all.