Although I've read about it it still doesn't sink in when you will need to pass in a variable. I think I know how i just don't know for what reason. If someone could provide that information for me i would appreciate it. Also, is PHP variable passing more efficient than doing so in HTML? Thanks for your time and help.

In what context are you referring?
Functions ?

function myFunction($var1, $var2){
return ($var1 + $var2);
}

In the example above I passed var1 and var2 into a function that adds them together and returns the result.

//call this function
$total =myFunction(1,2);

I passed 'hard coded' numbers here but variables could be used also

$a = 1;
$b =2;
$total =myFunction(a,b);

both will return 3 to $total

In what context are you referring?
Functions ?

function myFunction($var1, $var2){
return ($var1 + $var2);
}

In the example above I passed var1 and var2 into a function that adds them together and returns the result.

//call this function
$total =myFunction(1,2);

I passed 'hard coded' numbers here but variables could be used also

$a = 1;
$b =2;
$total =myFunction(a,b);

both will return 3 to $total

I'm sorry. I should have been more clear. I meant from one page to another.

So you are referring to something like this? <a href="whatever.com?variable=value">Example</a>

There are a lot of reasons, but the main reason I use them is to capture something specific in order to use it later. For example, say you've got a forum like daniweb. Each thread is essentially assigned an id to identify it. If a user is not logged in and tries to reply, they would be redirected to a login page first. But you need to keep track of the thread they were at. So you would pass a variable so the redirection script knows where they were initially to take them back there after log in. This is just one example of course.

So you are referring to something like this? <a href="whatever.com?variable=value">Example</a>

There are a lot of reasons, but the main reason I use them is to capture something specific in order to use it later. For example, say you've got a forum like daniweb. Each thread is essentially assigned an id to identify it. If a user is not logged in and tries to reply, they would be redirected to a login page first. But you need to keep track of the thread they were at. So you would pass a variable so the redirection script knows where they were initially to take them back there after log in. This is just one example of course.

Nice example. I welcome others with a little code illustration. Thanks everyone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.