About Lesson
2. Create a basic view
Now, we’ll make the basic view for our contact manager application.
Go to your xampp folder, open htdocs and create a new folder named ‘contact_manager’. Next, create 3 files: head.php, foot.php and index.php.
You’ll notice that we have header (head.php) and footer (foot.php) separated from index.php. We do this so that we can reuse them to make the code cleaner. To reuse them, we just have to include them in every page we need them in like the code below.
Create the file: head.php. Paste in the following code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contacts Manager</title> </head> <body>
Create the file: foot.php. Paste in the following code:
</body> </html>
Create the file: index.php. Paste in the following code:
Every new page we create, should include those two files.
<?php include('head.php'); ?> <h1>Contact Manager</h1> <!-- Replace this comment with your html and content --> <?php include('foot.php') ?>