如何使用函数在php中实现ajax

I would like to build a web app using json, ajax and php to be more clear, I need a php page with different functions that can be called from ajax method

Eg: phppage.php

addmydetails() 
{
   logic goes here
}

ajax page

/* Get from elements values */
 var values = $(this).serialize();

 $.ajax({
        url: "phppage.php/addmydetails",
        type: "post",
        data: values ,
        success: function (response) {
           // you will get response from your php page (what you echo or print)                 

        },
        error: function(jqXHR, textStatus, errorThrown) {
           console.log(textStatus, errorThrown);
        }


    });

So my actual question is that any option to call the function like this in ajax post url: "phppage.php/addmydetails"

No need for URL rewriting. Just get the PATH and use call_user_func. Something like this:

In your phppage.php:

$method = trim($_SERVER["PATH_INFO"], "/");

if(function_exists($method)){
    call_user_func($method);
    exit();
}

function Your_function_name(){
    print "this is my function";
}

Then you can access it using this URL --> phppage.php/Your_function_name