PHP questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
czy11421
Forum Newbie
Posts: 7
Joined: Sat Dec 26, 2009 9:03 pm

PHP questions

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP questions

Post 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?
Post Reply