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

Strings in PHP - PHP Tutorial

From the course: PHP for WordPress

Start my 1-month free trial

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.…

Contents