Here is a very simple and silly question I’m going to ask:
I’m very new to PHP, I was wondering if there is a way to call just a function in a class of PHP by AJAX.
for instance something like this:
$.ajax({
url:'newPHPClass.php/My_Function_Name'
...
});
So in php, it would be like:
<?php
class newPHPClass {
function My_Function_Name(){
}
}
?>
Why do I need this? So I wouldn’t have like so many php files. Instead I’ll have a single php class with different functions inside. It will look cleaner and less extra files.
I have used ASP.NET MVC C# before. and in ASP.NET I could just simply put my controller’s name in the URL section of AJAX followed by / and then my function’s name (which could be modified in my Global.asax.cs file).
Thanks.
And use
foo.php?action=method1as URL.