The first one is the more usual way of doing it, but the second will work if connect_db() is called. Since $conn isn't global, you need to type something like
PHP Code:
$foo = connect_db();
not 100% on that.
$foo will be your link after that. It's not a bad way of doing it if you plan on re-using the code lots.