Home >Backend Development >PHP Problem >PHP learning: in-depth understanding of strings
The previous article introduced to you "How should we use multiple nesting of if statements in PHP process control? ? ? 》, this article continues to introduce you to strings in PHP:
In the previous articles, we also mentioned related issues such as strings in PHP , in the next few days we will continue to explain in depth some other issues about strings: First, we will divide it into three parts to learn about PHP strings from the beginning:
Introduction to strings
Use of string
Use of string function library
1: PHP string Introduction
String is one of the important data types in PHP and is one of the scalar types;
A string is a series of characters, each character is a byte;
The string needs to be defined in single quotes, double quotes, and delimiters
(single quotes) The code demonstration is as follows:
<?php /*字符串定义在单引号中的使用 */ echo '人生十有八九不如意'; //在单引号引起来的字符串中不能再包含引号 //否则会报错。 //在单引号中如果在包含单引号需要使用转义字符'\'转义 ?>
The demonstration results are as follows:
(Double quotes) The code demonstration is as follows:
<?php $poem = '落花人独立,微雨燕双飞'; echo "$poem";//双引号可以解析变量,而单引号没有解析变量的作用 echo "<hr>"; echo "落花人独立,微雨燕双飞,{$poem}"; //可以用花括号{}括一个变量,就可以将变量分离出来解析,{}两边不要有空格 ?>
The demonstration results are as follows:
Recommended learning: "PHP Video Tutorial 》
The above is the detailed content of PHP learning: in-depth understanding of strings. For more information, please follow other related articles on the PHP Chinese website!