From the course: PHP for Non-Programmers
Printing information - PHP Tutorial
From the course: PHP for Non-Programmers
Printing information
- [Instructor] Output is incredibly important when working with php. It allows you to send results and other messages and texts to the user. So let's look at the various ways to output data. The simplest way to print something out on the screen is using phps echo statement. Echo tells php to print out whatever follows this word. You can also see that there are single quotes around hello world. There are nuanced differences between single and double quotes, but we'll get into that later. You can also see that the command ends with a semicolon. Because new lines are mostly for readability in php, in fact, you don't have to do a whole lot of spacing or new lines for the machine to understand php, php needs a signal or a delimiter, to let it know when a command ends. The semicolon serves that purpose. It's also worth noting that there are a few other ways to print or output in php, but since echo is by far the most common, that's what we will stick with. Finally, there are comments. Comments are a way for you to add nonfunctional code in php. In other words, you can leave notes to yourself or anyone else who views the code. With a double slash or with a forward slash and then asterisks, you can add a comment. Double forward slash is a single line comment and the forward slash followed by the asterisks is a multiline comment that ends with an asterisks and then a back slash. Keep an eye out in the exercise files for comments that add even more context to what you're looking at.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.