Receive a parameter from another file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mustafamisir
Forum Newbie
Posts: 23
Joined: Wed Jun 22, 2005 1:00 pm
Contact:

Receive a parameter from another file

Post by mustafamisir »

Hi,

In a .php page, I am making a list of some materials which have in formation in MySQL. And there is a link which calls another .php file with some parameters. And this called .php file creates a parameter that covers some value, and I want to receive it without going to this called page.

Is it possible?
If it, how can I have this parameter?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I'm a little unclear. You have two files (let's say A and B) - A has values it's pulled from MySQL. B generates some values as well. You want to be able to get variables and values from B, in A, without having to actually go to B.

Is that correct?

If so, require_once() may be what you need. That function opens and runs the required file inline.

Code: Select all

<?PHP

$first_var = 10;

?>

Code: Select all

<?PHP
$second_var = 2;

require_once('example_page.php');

echo $second_var * $first_var;//will output '20';
?>
Make sense?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mustafamisir
Forum Newbie
Posts: 23
Joined: Wed Jun 22, 2005 1:00 pm
Contact:

Post by mustafamisir »

if there are some paramaters that have the same name, how I will call these parameters?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If there are variables with the same name in file A and and file B, then those variables will be overwritten once B is included. You'll have to rename some variables in either file A or file B.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply