View Full Version : how can i pass parameters to an include file in php?

02-15-2010, 11:46 PM
how can i pass parameters to an include file in php?

means can we pass like that ? no . Why and what are the other solution

<?php include('includeFile.php')?var=2 ?>

Advance thanks
I am still trying to find solution

02-16-2010, 12:00 AM
I don't think so, but you should wait to hear back from someone more knowledgeable than me. :rolleyes:

What I'm really interested in, though, is your intention.
What are you trying to achieve?

There really are many ways to solve the same problem, and sharing you goals may reward you with more-helpful answers.

~ Mo

02-16-2010, 12:02 AM
I want to use that var variable in includeFile.php file do u understand or not

02-16-2010, 12:03 AM
No, you cannot do that, but then again, you shouldn't have to.

This will accomplish the same thing (assuming the variable in includeFile.php is named "$var"):

$var = 2;

02-16-2010, 02:14 AM
Yup just assign the variable in your code beforehand. If you're wanting to get them to work with $_GET then assign to $_GET

$_GET['var'] = 2;