Reputation: 115
I´m aware that with
loader = new URLLoader();
loader.data;
it´s possible to get the entire data/information from a php page.. But I don't want a php page for every bit of information I want from to 'stream'.
So my Question is: Is it possible to have multiple functions/methods in a php script, and only call the method I require?
such as:
<?php
function getColour1()
echo "blue";
function getColour2()
echo "red";
?>
If "yes", 2 lines of code that show how, or link to an example would be greatly appreciated.
cheers, M
Upvotes: 0
Views: 1128
Reputation: 8053
Check out the AMFPHP project: http://www.silexlabs.org/amfphp/
It does what you're looking for
Upvotes: 2
Reputation: 6403
$functionName = $_GET["action"];
$functionName() or call_user_func($functionName)
Upvotes: 0
Reputation: 22820
You want to hear about Front Controller Pattern.
Moreover, you need to route your request to different functions - I advise you to use this beautiful library, if you don't want to go with a full framework MVC stack.
Upvotes: 1
Reputation: 1343
You can pass an "action" variable to PHP, then use if/else statements in PHP tp respond to that action.
Upvotes: 2
Reputation: 1227
You could call the page like this:
http://www.site.com/script.php?action=getColour1
Then in your code:
<?php
switch($_GET["action"]) {
case "getColour1":
getColour1();
break;
case "getColour2":
getColour2();
break;
default:
echo "Unknown action";
break;
}
?>
Upvotes: 1