View Full Version : PHP equivalent to <jsp:param>

11-07-2006, 01:16 AM
This is my first post, so first let me say hello.

In JSP, I can pass parameter to an included page as follows:

<jsp:include page="page_include.jsp" flush="true">
<jsp:param name="buttonClicked" value="<%=submitBtn%>" />
<jsp:param name="navigation" value="<%=nav%>" />

Is there an equivalent in PHP? (I'm not talking about a simple include--require_once() and others--I mean, passing a param while including).

11-07-2006, 04:12 AM
PHP is very nice to you ...

If you create a variable on one page and call another page,
or include another page, your variable is already global. It will see
it in the other script without a need to pass it. So convenient.

.... an HTML <form> is a little different though.
<input type="textbox" name='myname' value=''>

The PHP script that reads the form:

So in summary ...
If both pages are .php types, variables are global, but if you are
passing from an HTML (.html) to a PHP (.php), you need to use
$_REQUEST to get the variable(s).

11-07-2006, 08:03 PM
So, in effect, it *is* simply requiring/including another php file (with the exception of html to php, as you note).

I agree that this is very convenient, as I find jsp:params can get rather verbose.


11-07-2006, 09:20 PM
Tim ....

And when/if you try it out and have problems, let us know and provide
a link (or some PHP scripting). That will help us to assist you better.
It sounds like you might be learning some PHP ... go for it.