Single quotes vs double quotes in PHP (plus how to do multi-line strings using heredocs and nowdocs)

preview_player
Показать описание

To define a string in PHP, you can surround some text with single quotes, or with double quotes. So what's the difference?

The difference is how the contents of the string are evaluated.

In this video we'll learn the difference between single-quoted strings and double-quoted strings in PHP. We'll also learn how to use a heredoc and nowdoc to easily create a multi-line string. We'll learn about variable interpolation in double-quoted strings, and escape sequences to insert special characters.

Resources:

Code shown in the video:

0:00 Intro
0:19 Single-quoted strings
1:01 Double-quoted strings
2:10 Performance
2:49 Heredocs
4:12 Nowdocs
4:46 Summary
Рекомендации по теме
Комментарии
Автор

Thanks you Dave for this importart note. 3+ year in PHP development and lear this tiny detail today. Never stop learning

fabrizio.anichini
Автор

Very well explained. Shared with my team.

winkbrace
Автор

Wow, I didn't know this and I have been using PHP for years.lol

KevinMpofu
Автор

What the hell... I feel like I should've known this years ago...

MobiusCoin