How to call a specific function in a PHP script via Ajax?

前端 未结 5 728
忘了有多久
忘了有多久 2021-02-06 15:53

Lets say I have a file called functions.php, and it has two separate functions inside:

One would get the time

And the other would get the date

How will I

5条回答
  •  遥遥无期
    2021-02-06 16:20

    you can add a parameter to the url:

    example:

    function.php?g=1
    

    now, on the serverside check for the get parameter:

    if($_GET['g']==1)
    {
        echo date();
    }
    else
    {
        echo time();
    }
    

提交回复
热议问题