We have a very basic knowledge of what PHP is. Now we're going to learn how to use it! You're first program hooray! What you're going to need:
- Your favorite text editor(mine's TextMate); Notepad is a timeless classic.
- A server running PHP, XAMPP is great if you're into not paying for things!
- The ability to learn and study! Woo! Studying!
How about we get started already? I want you to open up your favorite text editor and type in these lines:
What do these do you ask? This is how you declare that you are writing a PHP script. These tags are the most important to any PHP programmer. Without them we are useless and all of our code will show up as text in the browser. Lets start by making our program say something:
Now, I'm not going to assume that you're an idiot. It's clear what this program does, but again we find ourselves asking "but Ditoway, why the hell are you making me do something this simple?" That's easy. This is your first understanding of the syntax of this programming language. First we have our opening tag <?php next comes the most common function in almost every programming language, the PRINT function. You can guess what this does. Yes. It print's the input you give it, in this case we give the PRINT function a string of characters wrapped in quotation marks and followed by a semi-colon. The semi-colon denotes the end of a general program statement.
Now I know at first this is all hard to understand, you'll have questions like "but why the less-than symbols and question marks? what's with the semi-colon". If you're asking yourselves these questions then you need to stop and re-read this entire post. I've explained it already. And if you still don't understand it re-read this fucking post. By now you know what we're talking about. So save that file as anything.php and move the file to your server or run it in your terminal if you know how. But before you do that try and guess the output.
If you got that right you're ready to move on to the next lesson. If you still have any questions leave me a comment and I will answer to the best of my ability. Thanks for reading and I'll see you next time!