In this case I use:
<?php
include_once 'connect.php'; # connect with MySQL database
# some PHP code
?>
<!-- some HTML code -->
<?php
# here PHP code wants to use MySQL connection opened before
?>
Should I even include_once in 2nd PHP tag?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need to re-include a file if it’s within the same request/page.
Also, using
include_oncewill prevent you from including files that have already been included.You’re free to use again variables and connection previously included by your
connect.php