...

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



timshortt
11-07-2006, 12: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%>" />
</jsp:include>


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).

mlseim
11-07-2006, 03: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.
example:
<input type="textbox" name='myname' value=''>

The PHP script that reads the form:
$myname=$_REQUEST['myname'];

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).

timshortt
11-07-2006, 07: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.

Thanks

mlseim
11-07-2006, 08: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum