Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling php file fron another php file while passing arguments

Tags:

php

i need to call a php inside another php file and pass some arguments also. how can i do this?? i tried

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

if i write like

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

how can i solve this???

like image 860
su03 Avatar asked Mar 22 '11 10:03

su03


2 Answers

You don't have to pass anything in to your included files, your variables from the calling document will be available by default;

File1.php

<?php

$variable = "Woot!";
include "File2.php"; //if in the same folder

File2.php

<?php
echo $variable;
like image 104
Björn Avatar answered Oct 31 '22 02:10

Björn


the location in your code is incorrect:

$cmd = "/.../myfile.php?file=".$name;
like image 30
Charlie Avatar answered Oct 31 '22 01:10

Charlie