In general, there are several ways of separating functionality. You can conditionally include. You can conditionally execute. You can build your components in separate files and use a redirect to send arguments along:
header("Location: script2.php?foo=$foo&bar=$bar");