Call php file fron another php file when passing arguments

I need to call php inside another php file and pass some arguments. How can i do this?? I tried

include("http://.../myfile.php?file=$name"); 
  • but gives access denied. I read how v should not set allow_url_open to OFF.

if i write how

 $cmd = "/.../myfile.php?file=".$name"; $out =exec($cmd. " 2>&1"); echo $out; 
  • gives an error like /.../myfiles.php?file=hello: there is no such file or directory.

how can i solve this problem?

+7
source share
4 answers

You do not need to transfer anything to your included files, your variables from the calling document will be available by default;

File1.php

 <?php $variable = "Woot!"; include_file "File2.php"; 

File2.php

 <?php echo $variable; 
+14
source

you can include a file via http only if allow_url_fopen is set to TRUE, and the same parameter allows you to transfer variables to files ...

0
source

You should not include files over an HTTP connection, which is almost always a serious security issue.

If you must do this, you need to set allow_url_include and allow_url_fopen to ON , but none of them are recommended.

0
source

incorrect location of your code:

 $cmd = "/.../myfile.php?file=".$name"; 
0
source

All Articles