Jump to content

Run Function Via URL


N402KC

Recommended Posts

Howdy Yall,

 

Ive spent $200 on these damn PHP books and none of em tell me how to run functions. Only how to write the sons of code. Can yall help me in trying to figure out how i can do this. Here is what i wanna do;

 

For Example;

 

function hello()
{
      echo "Hello World";
}

 

That code is in a page called acars.php. Now when the user loads the page acars.php, nothing happens, but when they go to the url in this format. http://mydomain.com/acars.php/hello , Then it will echo Hello World.

 

Let me know what I can do and how I can do it please. Im startin to loose my patience lol. Thanks all.

Link to comment
https://forums.phpfreaks.com/topic/198455-run-function-via-url/
Share on other sites

I know how to run the function via code. But I want the function to code via the URL. So once the user goes to http://mydomain.com/acars.php/hello , It will run the function and display Hello World

 

O i gotcha - first post was a lil unclear

 

You would have the a link like:

<a href="./blah.php?run=hello">Say Hello</a>

 

Then when someone clicks it you need to check the array $_GET for the 'run' array key.

 

if(isset($_GET['run']) && $_GET['run'] == 'hello') {
  hello();
}

 

Read up on how to use $_GET, $_POST and html forms ..etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.