-3

Normally we execute php file by calling file_name.php from url, Instead of calling file_name from url can i call method/function from url to execute php file? If yes,please explain me with example.

Mad
  • 25
  • 1
  • 7
  • 1
    Yeah, why not allow anyone execute any code on your server?! – hynner Feb 10 '15 at 13:01
  • Something like this http://stackoverflow.com/questions/4360182/call-php-function-from-url ? – S. Moreno Feb 10 '15 at 13:02
  • 1
    You can execute anything you want? What are you asking? Are you looking for a router? – h2ooooooo Feb 10 '15 at 13:02
  • Please try to explain your problem in a clearer way. How are we supposed to know what you are talking about? – ksbg Feb 10 '15 at 13:02
  • my question is , we type the file_name.php in url but is that possible to call that file using method instead of calling its name.ext? – Mad Feb 10 '15 at 13:11

3 Answers3

0

Because it's unclear what you are asking for.

I think you want curl. Curl call will execute php script on your server.

Or you can execute code from a server with commands like php script.php

VeeeneX
  • 1,556
  • 18
  • 26
0

if I understand correctly: you wont to execute the content of anoder *.php file from widhin a php file.

just use "include":

include('path/to/my/file.php');

Look the definition for "include" here in the PHP manual

Hope ite helps

Federico
  • 1,231
  • 9
  • 13
0

you can use exec() php function. see this http://php.net/manual/en/function.exec.php

and to execute php file you can try this way.

exec('php path/to/your/phpfile.php');

for example:

exec('php /var/www/proj/home.php');

if your php file return something and you want to save it in variable then tyr this

exec('php /var/www/proj/home.php',$var);

if you want to call home.php from index.php then your index.php will look like

index.php

<?php
exec('php /var/www/proj/home.php');
?>
archish
  • 142
  • 1
  • 13