From the course: PHP for WordPress
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Strings in PHP
- [Instructor] Strings are an integral part of your work in PHP and WordPress because you're going to be printing out a lot of information on the screen. It's worth taking a closer look at how strings work and some of the things to keep in mind. First is single versus double quotes. The main difference between single and double quotes is that any string in double quotes will be processed by PHP before it's outputted. That means, for example, any variables in strings with double quotes will become their literal value. Let's take a look at a simple example. You see we have our age variable here, age gets 34, and then we have an echo statement with double quotes. Joe is age years old. If we run this code, you'll see the result is Joe is 34 years old. But if we switch these quotes to single quotes, save and run it again, you'll see that the variable is printed out because it's taken as a string and not as a variable.…
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
-
-
-
What is PHP?2m 1s
-
(Locked)
Printing information3m 15s
-
(Locked)
What are variables?6m
-
(Locked)
Strings in PHP5m 57s
-
(Locked)
Using arrays7m 59s
-
(Locked)
Arithmetic operators and math in PHP4m 38s
-
(Locked)
Challenge: Perform a mathematic operation and store it1m 14s
-
(Locked)
Solution: Perform a mathematic operation and store it3m 33s
-
-
-
-
-