For a tiny tiny project it won't hurt much to use global. When the project size starts growing is when things start to get bad.
if your somefunction()
had 300 lines in it using 5 global variables, someone looking at your code wouldn't know that the function uses outside variables unless they went through it looking for global variables.
Plus, it's so easy to not use global variables...so why do it
function somefunction( PDO $pdo ){
$statement = $pdo->prepare("some query");
$statement->execute();
}
EDIT:
show_profile.php
is your controller. Your controller collects all the data for the view and loads the view. This is a very simplified version.
require( 'functions.php' );
$db = new PDO();
$user = get_user( $db, $user_id );
require( 'view.php' );