From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Storing numbers and text in variables - PHP Tutorial
From the course: PHP for Web Designers
Storing numbers and text in variables
PHP variables can store many different types of information. For the time being, let's just focus on how you store numbers and text in a variable. We'll also look at the important role the semicolon plays in PHP. This page, variables.php, contains a simple template for a webpage about a book. I'm going to add my PHP code above the doc type, so if I put my insertion point up there, add in a couple of extra lines, then an opening PHP tag. Open angled bracket, question mark, PHP. And down here a closing tag which is a question mark and a closing angle bracket. It might seem strange to you that I'm putting the PHP code above the doc type. But remember, PHP code is processed by the server, and that's where it stays. So as long as the PHP code doesn't output any HTML, it's okay. Above the doc type, that will remain at the top of the page when it's received by the browser. So let's add our first variable. This one will be a number. We'll call it answer. Variables always begin with a dollar…
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.
Contents
-
-
-
How PHP makes web pages dynamic5m 23s
-
(Locked)
How to use PHP in a web page6m 43s
-
(Locked)
Using variables to store information2m 52s
-
(Locked)
Storing numbers and text in variables5m 18s
-
(Locked)
Displaying the values of number and text variables8m 9s
-
(Locked)
Using functions to manipulate values4m 36s
-
(Locked)
Adding comments to PHP scripts4m 46s
-
-
-
-
-
-
-
-