As developers, we need to build and process dynamic strings. Our code pulls in information from various sources, assembles it, and then renders it out to the browser. PHP provides a powerful function library to help us. In this hands-on lab, you will learn about the basics of PHP string building and processing.
What Will You Learn?
In this hands-on lab, you and I are going to ease into programming. You’ll learn about:
- Concatenating strings together
- Difference between
sprintf
andprintf
- Rendering strings out to the browser
- Checking for and finding substrings
- Replacing character or substrings
- Stripping out characters or entities
- Counting characters or length
- and more
Prerequisites
You will be writing code in this lab. You’ll need to have a basic local web development set up and ready to go. You can refer to this article in the Help Center to set up your local sandbox test website.
Create a dummy post called “WordPress Rocks”. Then populate the content using this post with the content from this gist.
Hands off the keyboard. Web development starts by thinking first, then planning it out, and then coding it.
Episodes
Total Lab Runtime: 02:50:33
- 1 Lab Introductionfree 09:39
- 2 Embedding Variables in a Stringpro 15:16
- 3 Embedding Complex Variablespro 13:37
- 4 Concatenating Strings with a Dotpro 08:47
- 5 Concatenating and Assigning Shorthandpro 05:58
- 6 Formatting a String using Placeholderspro 15:16
- 7 Specifying Which Argument in a Formatted Stringpro 04:18
- 8 Has Substringpro 21:47
- 9 Replacing Substringspro 13:03
- 10 Get the String's Lengthpro 14:11
- 11 Character Set Encoding - It Matters!pro 11:42
- 12 Has Substring - for UTF-8pro 16:45
- 13 Replacing a UTF-8 Substringpro 05:56
- 14 Stripping out Characters or Entitiespro 10:51
- 15 Wrap it Upfree 03:27