🐘
First contact with PHP
TL;DR
- Starting to build a website for my teacher's cake business
- Learning PHP as a server-side language for web applications
- Setting up a local development server with PHP's built-in server
- My first "Hello, World!" in PHP and understanding the basics
So, I'm trying to create a website for my teacher's cake business, and I decided to dive into PHP. The reason? I was told it's a good way to build web applications (like Facebook).
I started by figuring out where this code should run. That simple question always guides me when I'm programming. Where, when, how many times, and why are important things to understand before diving into the code itself.
Apparently, it runs inside a server. So, I had to set up a server and then put the code inside it to be interpreted.
Of course, the first thing I did was try to get something, anything, to show up on the screen!
To do that, I created a file named index.php
with the following content:
<?php
echo "Hello, World!";
?>
echo
is the command that tells PHP to output the text "Hello, World!" to the browser.
I discovered PHP has a built-in web server for testing purposes. It's simpler than setting up a full server stack. You can start it with this command in your project directory:
php -S localhost:8000
Then, you can access your site at http://localhost:8000
.
With this "Hello, World!", my plan now is to discover how to generate HTML with PHP so I can actually build a website for her.
No idea how to put this website online and make it accessible from outside my computer.
It's a start...
<- Back to blog
All rights not reserved. Do you want a website like this? Just copy it 👍🏾