We knew about PHP string in out past articles. But here we are going to discuss details about PHP String. PHP string is most important to PHP Career. Let's know how we create and use PHP String. At first, we need to create it to use, then we can use that in function or script. It can store a value. In the example, bellow sees that we use a string in a variable and we declare by echo.
Output Life is beautiful.Life is beautiful.
$the_string = "Life is beautiful.";
echo "Life is beautiful.";
In this example, we insert a string into $the_string variable and we execute another string using echo without store any variable. We should focus that we will store a string into a variable when we use this variable in many places in a script. ok save the above code and run this, then this will execute like this.
we used PHP String by Double quotes but we can also create a string using Single quotes, we know single quotes as apostrophes. Let's see the example
If we use 'Single quote' in Single quotes string then we need to use that like it,
$the_string = 'Life is beautiful.';
echo 'Life is beautiful.';
We used a backslash in this string. Double quote string is more helpful from the single quote.
echo 'PHPAns is pretty, isn\'t it?';