Home >Backend Development >PHP Tutorial >Understanding PHP String Principles_PHP Tutorial

Understanding PHP String Principles_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:34:36751browse

Many times we use PHP strings, and how PHP strings are composed, it is estimated that few people understand this~

In fact, PHP string is a character array. Suppose we define a string

$string ="hello world";

/*

This string is composed of h, e, l, l, o, space, w, o, r, l, d. As for what it ends with, I can understand it now. You may need to check the PHP original Code can be discovered

*/

//What is the basis for what I said above? You can test it below

echo $string[2];//The third character l is displayed, we can try to change

$string[2]="A";//Change one of the characters;

echo $string;// get heAlo world

//Then we can try to change $string[2] to string

$string[2]="AAAAAA";//Test to see if PHP will overwrite the following characters

echo $string;// Get heAlo world , haha. It seems that PHP has done safety processing

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508457.htmlTechArticleMany times we use PHP strings and how are PHP strings composed? It is estimated that few people understand this Understand~ In fact, PHP string is a character array. Suppose we define a string...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn