Page 1 of 1

PHP questions

Posted: Sat Dec 26, 2009 9:10 pm
by czy11421
I am from java/j2ee, new to PHP, some questions:

1. if I put all functions into functions.php, then how can I call one specified function when submitting a form ? In J2EE, if using Spring framework, we can use different controller to achieve this ?

2. how could I redirect a page ? in java Servlet, we can use redirect/forward , what about PHP ?

3. PHP has filter concept ? if yes ,how to implement it ?

Thanks.

Re: PHP questions

Posted: Sat Dec 26, 2009 9:31 pm
by requinix
czy11421 wrote:1. if I put all functions into functions.php, then how can I call one specified function when submitting a form ? In J2EE, if using Spring framework, we can use different controller to achieve this ?
If you're comparing vanilla PHP to Java + Spring then you're off to a bad start.

Use include or require to "execute" a file. That'll define the functions and then you can use them.
czy11421 wrote:2. how could I redirect a page ? in java Servlet, we can use redirect/forward , what about PHP ?
Before you output anything,

Code: Select all

header("Location: http://www.example.com/path/to/new/location");
exit;
The call to exit() is important.
czy11421 wrote:3. PHP has filter concept ? if yes ,how to implement it ?
What kind of filters? You mean like this?