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.
ASPso you could have passed yourcontroller nameandmethod nameeasily because those frameworks were designed with routing but if you want to do same thing inphpthen it's possible usingphpframeworks (like laravel, or other) otherwise you can't just passclass nameandmethod name, it won't work this way.