Types of PHP Strings
Learn about different types of PHP strings with the help of examples.
We have covered a lot of ground so far but have not taken much time to look at how we can create strings in PHP. PHP provides four different ways to define strings:
- Single-quoted strings
- Double-quoted strings
- Heredoc strings
- Nowdoc strings
Single quoted strings
One of the most common string syntaxes we find is the single-quote syntax. Using this syntax, we wrap the contents of our string with single quotes:
Press + to interact
<?php// Outputs A single quote string.echo 'A single quote string.';
The benefit of the single-quote syntax is that all escape sequences (beyond escaping a single ...
Get hands-on with 1400+ tech skills courses.