By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Accessing functions through a URL?

P: n/a
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php

function a_function() {echo "Hello!";}

?>
Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.
P.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.514 / Virus Database: 312 - Release Date: 28/08/2003
Jul 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
The Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


Hi,

It's definitely not possible.

HTH;
JOn
Jul 16 '05 #2

P: n/a
Hi,

Sure it's possible. You can analyse the url. See if there are strings after
the ?. Next you need to check if that string is a function. If it is....
run it. So if you can program a little bit, it is possible...

Kind regards,

Dirk

Jon Kraft wrote:
The Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


Hi,

It's definitely not possible.

HTH;
JOn


--
BOFH Excuse #380:

Operators killed when huge stack of backup tapes fell over.

Jul 16 '05 #3

P: n/a
Dirk Engels <d.******@student.utwente.nl> wrote:
Jon Kraft wrote:
The Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:
Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.


It's definitely not possible.


Sure it's possible. You can analyse the url. See if there are strings
after the ?. Next you need to check if that string is a function. If it
is.... run it. So if you can program a little bit, it is possible...


Hi Dirk,

I didn't say it wouldn't be possible for a script to call the function after
analysing the requested url - I merely confirmed that it is absolutely
impossible to call a function through a URL.

http://www.somesiteorother.com/test.php?a_function will never invoke the
function a_function().

JOn
Jul 16 '05 #4

P: n/a
Hi,

Not directly... but there is always a way to do something you want to do...
the sky is the limit :-)

dirk

Jon Kraft wrote:
Dirk Engels <d.******@student.utwente.nl> wrote:
Jon Kraft wrote:
The Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:

Is it possible to access a function in a php document through a URL?

For instance: http://www.somesiteorother.com/test.php?a_function

And then have something like this in test.php:

<?php
function a_function() {echo "Hello!";}
?>

Or is this definitely not possible? I'm assuming it would definitely be
impossible for security reasons... which is what I'm hoping.

It's definitely not possible.


Sure it's possible. You can analyse the url. See if there are strings
after the ?. Next you need to check if that string is a function. If it
is.... run it. So if you can program a little bit, it is possible...


Hi Dirk,

I didn't say it wouldn't be possible for a script to call the function
after analysing the requested url - I merely confirmed that it is
absolutely impossible to call a function through a URL.

http://www.somesiteorother.com/test.php?a_function will never invoke the
function a_function().

JOn


--
BOFH Excuse #220:

Someone thought The Big Red Button was a light switch.

Jul 16 '05 #5

P: n/a
Dirk Engels wrote:
Hi,

Not directly... but there is always a way to do something you want to do...
the sky is the limit :-)

dirk


Indeed, it is ;-)) And sometimes its really simple too. I will show you.
>Is it possible to access a function in a php document through a URL?
>
>For instance: http://www.somesiteorother.com/test.php?a_function
>
>And then have something like this in test.php:
>
><?php
>function a_function() {echo "Hello!";}
$_GET["function"]();
?>


But, you would have to access it through:

http://www.somesiteorother.com/test....ion=a_function

The trick used here is that you can use any variable as a variable or function name. Similarly you can use $$variable.

Michiel.

Jul 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.