Of course it is possible.
But question is if it is good?
To put 'it all' in same php page.
Many prefer to have separate pages, for separate actions.
For example 'login.php' / 'logout.php'
You only have to login 1 time.
Why should the phpscript include the code that handles login
when user is already logged in?
The main consideration may be:
- things that are used 1 time or few times, should be separate.
- things/functions that are used over and over, should be in main script
... or more correct
should be included in the main script.
It can still be a separate file, but included using for example:
include( 'common_functions.php' );
It is also possible to make conditional includes:
if( this and that ){
include( 'this_and_that.php' )
}
Regards