The second method is preferred: one index.php
file which drives the entire application/website.
As for breaking down the application,
you'll use both: parameters in the URL, to decide what is to be done, and helper functions which receive parameters and do their job.
The challenge is to break down the "big problem" in smaller, reusable "sub-problems" and wrap each in a reusable function.
After that, solving the "big problem" is a matter of sticking together function calls, like you do in a puzzle game.
Now, that was the way to go at your beginner level, at a more advanced level you would break it down in an OOP manner, to take advantage of autoloading (read my response there for details).
Right in-between the two levels of experience, you could try first to use a procedural php framework like http://www.limonade-php.net/, and second to understand its code and learn from it. This should put you on the right track for more advanced uses of PHP.
None of your presented options have something particular in respect to security or performance, they're both the same. Breaking it down in functions is a matter of code reusability and maintainability. That being said, the OOP is still better in any regards (again, I'll have to point at my other answer).
As I said, you'll use both, AND you'll have to validate the input (that is, $_REQUEST
$_GET
, $_POST
, $_COOKIE
, $_SESSION
, $_FILE
, (some elements from) $_SERVER
). Be careful with XSS (basically, you'll use either strip_tags()
or htmlentities()
or a combination of the two). That's about the security aspect.