Strings in PHP7
If you have been following along in our lessons we have used several strings. A string in PHP can be encapsulated with single or double quotes. A PHP string is made up of several letters, numbers and even code like HTML, javaScript and CSS. Here is an example of a string.
<?php $var="I Love PHP7" var_dump($var);?>
This is the result. When you use var_dump it returns the value and also the number of characters that are in a string.
string(11) “I love PHP7”
Using Strings With Code in PHP7
You can use strings to hold code in PHP. We have done this a few times already in our lessons. Here is an example.
<?php $string=' <h3>PHP7 Is Awesome</h3>'; echo $string; ?>
When Would I Use String in PHP7?
You will use strings all the time in PHP7. They are used everywhere and practically on every page. Creating a string is simple and easy to use, that may be why we use them so often.
A1WEBSITEPRO Social Media Pages
Here are my social media pages, lets hook up!