COMP3512
winter 2024
lec-php-02

Down the Road

RECALL
- Our Codespaces have an Apache webserver. What's it's job?
- Say we go to https://blah/foo.php. What happens under the hood?
- What do we have to do in a Codespace to make sure it's visible to JP?
- Where do our PHP files need to live for them to be accessible?
let's answer these questions today:
◉ Why even use PHP?
◉ How should I arrange my code in a PHP file so I don't go batty?
◉ What's going on with The Project?
◉ When do I have to do my two Chats?
The Project & Lab Chats
PHP
What's going on with The Project?
When do I have to do my two Chats?
I'm glad you asked. Let's get random.
Why even use PHP?
It let's us create dynamic, not static websites.
<html>Taste the rainbow.
Making a PHP page is like making a Mad Libs sheet.

A very good habit to get into:
- Make a PHP page that's just HTML - use hard-coded placeholder values for the things that will eventually change.
- When you're happy with how things look...
- Replace the placeholders with PHP that echoes out the dynamic content.
Let's give it a try.
Hello, World - here we come.
Let's try some loops.
Days of the week, anyone?


BRAIN BREAK
How should I arrange my code in a PHP file so I don't go batty?
It is CRAZY EASY to make a mess of a PHP source file.
Let's show you some things to alleviate the pain.
We want to continue to separate pages into a data collection part and a presentation part.
We can use views to make things easier on our brains, too.
We can break things down even further by using partials.
lec-php-02
By Jordan Pratt
lec-php-02
project stuff | making PHP manageable
- 195