Hướng dẫn what is string with example in php? - chuỗi với ví dụ trong php là gì?


Một chuỗi là một chuỗi các nhân vật, như "Hello World!".


Chức năng chuỗi PHP

Trong chương này, chúng tôi sẽ xem xét một số chức năng thường được sử dụng để thao tác các chuỗi.


strlen () - Trả về độ dài của chuỗi

Hàm Php

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
1 trả về độ dài của một chuỗi.

Thí dụ

Trả về độ dài của chuỗi "Hello World!":

echo strlen("Hello world!"); // outputs 12
?>

Hãy tự mình thử »


str_word_count () - Đếm các từ trong chuỗi

Hàm Php

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
2 đếm số lượng từ trong một chuỗi.

Thí dụ

Trả về độ dài của chuỗi "Hello World!":

echo str_word_count("Hello world!"); // outputs 2
?>

Hãy tự mình thử »



str_word_count () - Đếm các từ trong chuỗi

Hàm Php

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
2 đếm số lượng từ trong một chuỗi.

Thí dụ

Trả về độ dài của chuỗi "Hello World!":

echo strrev("Hello world!"); // outputs !dlrow olleH
?>

Hãy tự mình thử »


str_word_count () - Đếm các từ trong chuỗi

Hàm Php

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
2 đếm số lượng từ trong một chuỗi.

Thí dụ

Trả về độ dài của chuỗi "Hello World!":

echo strpos("Hello world!", "world"); // outputs 6
?>

Hãy tự mình thử »

str_word_count () - Đếm các từ trong chuỗi The first character position in a string is 0 (not 1).


Hàm Php PHP Parse error: Invalid indentation - tabs and spaces cannot be mixed in example.php line 8 2 đếm số lượng từ trong một chuỗi.

Đếm số lượng từ trong chuỗi "Hello World!":

Thí dụ

Trả về độ dài của chuỗi "Hello World!":

echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
?>

Hãy tự mình thử »


str_word_count () - Đếm các từ trong chuỗi

Hàm Php

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
2 đếm số lượng từ trong một chuỗi.

Đếm số lượng từ trong chuỗi "Hello World!":


strrev () - đảo ngược một chuỗi



Chuỗi với một ví dụ là gì?string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support. See details of the string type.

Một chuỗi là bất kỳ loạt ký tự nào được giải thích theo nghĩa đen bởi một kịch bản. Ví dụ: "Hello World" và "LKJH019283" đều là những ví dụ về chuỗi. Trong lập trình máy tính, một chuỗi được gắn vào một biến như trong ví dụ dưới đây.: On 32-bit builds, a string can be as large as up to 2GB (2147483647 bytes maximum)

Ý bạn là gì khi chuỗi trong PHP?

Thuật ngữ "chuỗi" đề cập đến một loạt các ký tự. PHP hỗ trợ một số loại dữ liệu, bao gồm cả chuỗi. Các ký tự chữ và số được cho phép trong các biến chuỗi.string literal can be specified in four different ways:

  • Chuỗi giải thích các loại chuỗi khác nhau trong PHP là gì?
  • Chuỗi PHP là một chuỗi các ký tự, tức là được sử dụng để lưu trữ và thao tác văn bản. PHP chỉ hỗ trợ bộ 256 ký tự và do đó nó không cung cấp hỗ trợ Unicode gốc. Có 4 cách để chỉ định một chuỗi theo nghĩa đen trong PHP. được trích dẫn đơn. Double Trích dẫn.
  • Một chuỗi là loạt các ký tự, trong đó một ký tự giống như một byte. Điều này có nghĩa là PHP chỉ hỗ trợ bộ 256 ký tự và do đó không cung cấp hỗ trợ Unicode gốc. Xem chi tiết của loại chuỗi.
  • Lưu ý: Trên các bản dựng 32 bit, một chuỗi có thể lớn lên tới 2GB (2147483647 BYTE TỐI ĐỘ)

Cú pháp

Một chuỗi chữ có thể được chỉ định theo bốn cách khác nhau:string is to enclose it in single quotes (the character

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
6).

được trích dẫn đơn

Double Trích dẫn: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
1

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
2

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
3

HEREDOC Cú pháp

Cú pháp NowDocstring is enclosed in double-quotes ("), PHP will interpret the following escape sequences for special characters:

Được trích dẫn đơn
Cách đơn giản nhất để chỉ định một chuỗi là đặt nó trong các trích dẫn đơn (ký tự
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
6).
Để chỉ định một trích dẫn đơn theo nghĩa đen, hãy thoát nó bằng một dấu gạch chéo ngược (
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
7). Để chỉ định một dấu gạch chéo ngược theo nghĩa đen, nhân đôi nó (
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
8). Tất cả các trường hợp khác của dấu gạch chéo ngược sẽ được coi là một dấu gạch chéo ngược theo nghĩa đen: điều này có nghĩa là các chuỗi thoát khác mà bạn có thể được sử dụng, chẳng hạn như
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
9 hoặc
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
0, sẽ được đầu ra theo nghĩa đen theo nghĩa đen thay vì có bất kỳ ý nghĩa đặc biệt nào.
Lưu ý: Không giống như các cú pháp, các biến và trình tự thoát được trích dẫn kép và heredoc cho các ký tự đặc biệt sẽ không được mở rộng khi chúng xảy ra trong các chuỗi được trích dẫn đơn.Double Trích dẫn
Nếu chuỗi được đặt trong các trình điều khiển kép ("), PHP sẽ diễn giải các chuỗi thoát sau đây cho các ký tự đặc biệt:Những nhân vật đã trốn thoát
Sự phối hợpNghĩa
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
0
LineFeed (LF hoặc 0x0a (10) trong ASCII)
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
9
Trở lại vận chuyển (CR hoặc 0x0D (13) trong ASCII)
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
6
Tab ngang (HT hoặc 0x09 (9) trong ASCII)
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
7
Tab dọc (VT hoặc 0x0b (11) trong ASCII)
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
8
Escape (ESC hoặc 0x1B (27) trong ASCII)
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
9
Form Feed (FF hoặc 0x0C (12) trong ASCII)
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
8
dấu vết chéo ngược
PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
1
ký hiệu đô la
PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
2
kép

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
3strings, escaping any other character will result in the backslash being printed too.

Trình tự các ký tự khớp với biểu thức chính quy là một ký tự trong ký hiệu bát phân, âm thầm tràn để phù hợp với byte (ví dụ: "\ 400" === "\ 000")strings is the fact that variable names will be expanded. See string parsing for details.

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
4

Trình tự các ký tự phù hợp với biểu thức chính quy là một ký tự trong ký hiệu thập lục phânstrings is the heredoc syntax:

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
6. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
5

Ngoài ra, mã định danh đóng phải tuân theo các quy tắc đặt tên giống như bất kỳ nhãn nào khác trong PHP: nó chỉ chứa các ký tự chữ và số và gạch dưới, và phải bắt đầu với ký tự không chữ số hoặc dấu gạch dưới.

Ví dụ #1 Ví dụ về Heredoc cơ bản kể từ Php 7.3.0

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
7

Đầu ra của ví dụ trên trong Php 7.3:

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:ParseError will be thrown:

Ví dụ #2 Định danh đóng không được thụt vào nhiều hơn bất kỳ dòng nào của cơ thể

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
8

Đầu ra của ví dụ trên trong Php 7.3:

PHP Parse error:  Invalid body indentation level (expecting an indentation level of at least 3) in example.php on line 4

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:ParseError will be thrown. These whitespace constraints have been included because mixing tabs and spaces for indentation is harmful to legibility.

Ví dụ #2 Định danh đóng không được thụt vào nhiều hơn bất kỳ dòng nào của cơ thể

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
9

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
0

Tuy nhiên, nếu định danh đóng được thụt vào, các tab cũng có thể được sử dụng, tuy nhiên, các tab và khoảng trống không được kết hợp liên quan đến việc thụt vào định danh đóng và thụt của cơ thể (lên đến định danh đóng). Trong bất kỳ trường hợp nào trong số này, một người sinh viên sẽ bị ném. Những ràng buộc khoảng trắng này đã được đưa vào vì trộn các tab và không gian để thụt vào có hại cho tính dễ đọc.

Đầu ra của ví dụ trên trong Php 7.3:

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:

Ví dụ #2 Định danh đóng không được thụt vào nhiều hơn bất kỳ dòng nào của cơ thể

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
2

Đầu ra của ví dụ trên trong Php 7.3:

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:

Ví dụ #2 Định danh đóng không được thụt vào nhiều hơn bất kỳ dòng nào của cơ thểParseError.

Tuy nhiên, nếu định danh đóng được thụt vào, các tab cũng có thể được sử dụng, tuy nhiên, các tab và khoảng trống không được kết hợp liên quan đến việc thụt vào định danh đóng và thụt của cơ thể (lên đến định danh đóng). Trong bất kỳ trường hợp nào trong số này, một người sinh viên sẽ bị ném. Những ràng buộc khoảng trắng này đã được đưa vào vì trộn các tab và không gian để thụt vào có hại cho tính dễ đọc.

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
3

Đầu ra của ví dụ trên trong Php 7.3:

PHP Parse error:  syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:

Nếu mã định danh đóng được thụt vào hơn bất kỳ dòng nào của cơ thể, thì sẽ bị ném parseerror:

Ví dụ #2 Định danh đóng không được thụt vào nhiều hơn bất kỳ dòng nào của cơ thể

Tuy nhiên, nếu định danh đóng được thụt vào, các tab cũng có thể được sử dụng, tuy nhiên, các tab và khoảng trống không được kết hợp liên quan đến việc thụt vào định danh đóng và thụt của cơ thể (lên đến định danh đóng). Trong bất kỳ trường hợp nào trong số này, một người sinh viên sẽ bị ném. Những ràng buộc khoảng trắng này đã được đưa vào vì trộn các tab và không gian để thụt vào có hại cho tính dễ đọc.

Ví dụ #3 thụt khác nhau cho cơ thể (không gian) Định danh đóng

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
6

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
1

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
7

Định danh đóng cho chuỗi cơ thể không bắt buộc phải được theo sau bởi dấu chấm phẩy hoặc dòng mới. Ví dụ: mã sau được cho phép kể từ Php 7.3.0:

Ví dụ #tiếp tục biểu thức sau khi nhận dạng đóngstring, without the double quotes. This means that quotes in a heredoc do not need to be escaped, but the escape codes listed above can still be used. Variables are expanded, but the same care must be taken when expressing complex variables inside a heredoc as with strings.

Cảnh báo

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
8

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
9

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
0

Nếu định danh đóng được tìm thấy khi bắt đầu một dòng, thì bất kể đó là một phần của một từ khác, nó có thể được coi là định danh đóng và gây ra một parseerror.

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A

Ví dụ #5 Đóng định danh trong phần thân của chuỗi có xu hướng gây ra parseerror

Để tránh vấn đề này, bạn có thể tuân theo quy tắc đơn giản: không chọn định danh đóng xuất hiện trong phần thân của văn bản.

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
1

Trước PHP 7.3.0, điều rất quan trọng cần lưu ý là dòng có định danh đóng phải chứa các ký tự khác, ngoại trừ dấu chấm phẩy (

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
4). Điều đó có nghĩa là đặc biệt là định danh có thể không được thụt vào và có thể không có bất kỳ khoảng trống hoặc tab nào trước hoặc sau dấu chấm phẩy. Điều quan trọng nữa là nhận ra rằng ký tự đầu tiên trước khi định danh đóng phải là một dòng mới theo định nghĩa của hệ điều hành cục bộ. Đây là
array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
0 trên các hệ thống UNIX, bao gồm cả macOS. DELIMITER đóng cũng phải được theo sau bởi một dòng mới.

Nếu quy tắc này bị phá vỡ và định danh đóng không "sạch", nó sẽ không được coi là một định danh đóng và PHP sẽ tiếp tục tìm kiếm một định danh. Nếu không tìm thấy mã định danh đóng thích hợp trước khi kết thúc tệp hiện tại, lỗi phân tích cú pháp sẽ dẫn đến dòng cuối cùng.

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
2

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
3

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
4

Ví dụ #6 Ví dụ không hợp lệ, trước Php 7.3.0

Ví dụ #7 Ví dụ hợp lệ, ngay cả khi trước PHP 7.3.0

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
5

Heredocs chứa các biến không thể được sử dụng để khởi tạo các thuộc tính lớp.

Văn bản Heredoc hoạt động giống như một chuỗi được trích dẫn kép, không có trích dẫn kép. Điều này có nghĩa là các trích dẫn trong Heredoc không cần phải thoát ra, nhưng các mã thoát được liệt kê ở trên vẫn có thể được sử dụng. Các biến được mở rộng, nhưng phải cẩn thận khi biểu thị các biến phức tạp bên trong heredoc như với các chuỗi.

Ví dụ #8 ví dụ về chuỗi heredoc trích dẫn

Ví dụ trên sẽ xuất ra:

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.
9

Ví dụ trên sẽ xuất ra:

Example of string spanning multiple lines
using nowdoc syntax. Backslashes are always treated literally,
e.g. \\ and \'.

Ví dụ #13 NowDoc Chuỗi trích dẫn ví dụ với các biến

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
0

My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
9

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
2

Ví dụ trên sẽ xuất ra:

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41

Ví dụ #14 Ví dụ dữ liệu tĩnh

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
3

Phân tích phân tích biến đổi

Khi một chuỗi được chỉ định trong trích dẫn kép hoặc với Heredoc, các biến được phân tích cú pháp trong đó.string is specified in double quotes or with heredoc, variables are parsed within it.

Có hai loại cú pháp: một loại đơn giản và một loại phức tạp. Cú pháp đơn giản là phổ biến và thuận tiện nhất. Nó cung cấp một cách để nhúng một biến, giá trị mảng hoặc thuộc tính đối tượng trong một chuỗi với nỗ lực tối thiểu.array value, or an object property in a string with a minimum of effort.

Cú pháp phức tạp có thể được nhận ra bởi niềng răng xoăn xung quanh biểu thức.

Cú pháp đơn giản

Nếu một dấu hiệu đô la (

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
4) gặp phải, trình phân tích cú pháp sẽ tham lam lấy càng nhiều mã thông báo càng tốt để tạo ra một tên biến hợp lệ. Kèm theo tên biến trong niềng răng xoăn để chỉ định rõ ràng phần cuối của tên.

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
5

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
2

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
7

Ví dụ trên sẽ xuất ra:

He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.

Tương tự, một chỉ mục mảng hoặc thuộc tính đối tượng có thể được phân tích cú pháp. Với các chỉ số mảng, khung hình vuông đóng (

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
8) đánh dấu sự kết thúc của chỉ số. Các quy tắc tương tự áp dụng cho các thuộc tính đối tượng như các biến đơn giản.array index or an object property can be parsed. With array indices, the closing square bracket (
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
8) marks the end of the index. The same rules apply to object properties as to simple variables.

Ví dụ #15 Ví dụ về cú pháp đơn giản

My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
9

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
2

He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
1

Ví dụ trên sẽ xuất ra:

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .

Kể từ Php 7.1.0, các chỉ số số âm được hỗ trợ.

Ví dụ #16 Chỉ số số âm

He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
2

Ví dụ trên sẽ xuất ra:

The character at index -2 is n.
Changing the character at index -3 to o gives strong.

Đối với bất cứ điều gì phức tạp hơn, bạn nên sử dụng cú pháp phức tạp.

Cú pháp phức tạp (xoăn)

Điều này không được gọi là phức tạp vì cú pháp rất phức tạp, nhưng vì nó cho phép sử dụng các biểu thức phức tạp.

Bất kỳ biến vô hướng, phần tử mảng hoặc thuộc tính đối tượng có biểu diễn chuỗi có thể được bao gồm thông qua cú pháp này. Biểu thức được viết giống như nó sẽ xuất hiện bên ngoài chuỗi, và sau đó được bọc trong

He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3 và
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
4. Vì
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3 không thể thoát ra được, cú pháp này sẽ chỉ được nhận ra khi
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
4 ngay lập tức theo
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3. Sử dụng
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
8 để có được một
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
9 theo nghĩa đen. Một số ví dụ để làm cho nó rõ ràng:string representation can be included via this syntax. The expression is written the same way as it would appear outside the string, and then wrapped in
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3 and
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
4. Since
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3 can not be escaped, this syntax will only be recognised when the
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
4 immediately follows the
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
3. Use
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
8 to get a literal
He drank some apple juice.
He drank some juice made of .
He drank some juice made of apples.
9. Some examples to make it clear:

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
0

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
2

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
2

Cũng có thể truy cập các thuộc tính lớp bằng cách sử dụng các biến trong các chuỗi bằng cú pháp này.

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
3

Ví dụ trên sẽ xuất ra:

Ghi chú::

Giá trị được truy cập từ các hàm, cuộc gọi phương thức, biến lớp tĩnh và hằng số lớp bên trong

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
4 sẽ được hiểu là tên của một biến trong phạm vi mà chuỗi được xác định. Sử dụng niềng răng xoăn đơn (
He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
5) sẽ không hoạt động để truy cập các giá trị trả về của các hàm hoặc phương thức hoặc các giá trị của hằng số lớp hoặc biến lớp tĩnh.

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
6

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
7

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
8

Truy cập và sửa đổi chuỗi theo ký tự

Các ký tự trong các chuỗi có thể được truy cập và sửa đổi bằng cách chỉ định độ lệch dựa trên 0 của ký tự mong muốn sau chuỗi sử dụng khung mảng vuông, như trong $ str [42]. Hãy nghĩ về một chuỗi như một mảng các ký tự cho mục đích này. Có thể sử dụng các hàm Subr () và Subr_Replace () khi bạn muốn trích xuất hoặc thay thế nhiều hơn 1 ký tự.strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. Think of a string as an array of characters for this purpose. The functions substr() and substr_replace() can be used when you want to extract or replace more than 1 character.

Lưu ý: Kể từ Php 7.1.0, độ lệch chuỗi âm cũng được hỗ trợ. Chúng chỉ định độ lệch từ cuối chuỗi. Trước đây, độ lệch âm phát ra

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
9 để đọc (mang lại một chuỗi trống) và
The character at index -2 is n.
Changing the character at index -3 to o gives strong.
0 để viết (khiến chuỗi không bị ảnh hưởng).
: As of PHP 7.1.0, negative string offsets are also supported. These specify the offset from the end of the string. Formerly, negative offsets emitted
He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
9
for reading (yielding an empty string) and
The character at index -2 is n.
Changing the character at index -3 to o gives strong.
0
for writing (leaving the string untouched).

Lưu ý: Trước Php 8.0.0, các chuỗi cũng có thể được truy cập bằng niềng răng, như trong $ str {42}, cho cùng một mục đích. Cú pháp nẹp xoăn này đã được dùng hết là Php 7.4.0 và không còn được hỗ trợ kể từ Php 8.0.0.: Prior to PHP 8.0.0, strings could also be accessed using braces, as in $str{42}, for the same purpose. This curly brace syntax was deprecated as of PHP 7.4.0 and no longer supported as of PHP 8.0.0.

Cảnh báo

Viết vào một miếng đệm ngoài phạm vi Chuỗi với khoảng trắng. Các loại không số nguyên được chuyển đổi thành số nguyên. Loại bù bất hợp pháp phát ra

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
0. Chỉ có ký tự đầu tiên của chuỗi được gán được sử dụng. Kể từ Php 7.1.0, việc gán một chuỗi trống ném một lỗi nghiêm trọng. Trước đây, nó đã chỉ định một byte null.
The character at index -2 is n.
Changing the character at index -3 to o gives strong.
0
. Only the first character of an assigned string is used. As of PHP 7.1.0, assigning an empty string throws a fatal error. Formerly, it assigned a NULL byte.

Cảnh báo

Viết vào một miếng đệm ngoài phạm vi Chuỗi với khoảng trắng. Các loại không số nguyên được chuyển đổi thành số nguyên. Loại bù bất hợp pháp phát ra

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
0. Chỉ có ký tự đầu tiên của chuỗi được gán được sử dụng. Kể từ Php 7.1.0, việc gán một chuỗi trống ném một lỗi nghiêm trọng. Trước đây, nó đã chỉ định một byte null.

Trong nội bộ, chuỗi PHP là mảng byte. Do đó, việc truy cập hoặc sửa đổi một chuỗi bằng cách sử dụng khung mảng không an toàn nhiều byte và chỉ nên được thực hiện với các chuỗi trong mã hóa một byte như ISO-8859-1.: As of PHP 7.1.0, applying the empty index operator on an empty string throws a fatal error. Formerly, the empty string was silently converted to an array.

Lưu ý: Kể từ Php 7.1.0, việc áp dụng toán tử chỉ mục trống trên một chuỗi trống ném một lỗi nghiêm trọng. Trước đây, chuỗi trống được chuyển đổi âm thầm thành một mảng.

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
2

Ví dụ #17 Một số ví dụ chuỗi

Các độ lệch chuỗi phải là số nguyên hoặc các chuỗi giống như số nguyên, nếu không một cảnh báo sẽ được đưa ra.

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
3

Ví dụ trên sẽ xuất ra:

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
0

Ghi chú::

Giá trị được truy cập từ các hàm, cuộc gọi phương thức, biến lớp tĩnh và hằng số lớp bên trong

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
4 sẽ được hiểu là tên của một biến trong phạm vi mà chuỗi được xác định. Sử dụng niềng răng xoăn đơn (
He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
5) sẽ không hoạt động để truy cập các giá trị trả về của các hàm hoặc phương thức hoặc các giá trị của hằng số lớp hoặc biến lớp tĩnh.
The character at index -2 is n.
Changing the character at index -3 to o gives strong.
6
.

Ghi chú::

Các ký tự trong các chuỗi chữ có thể được truy cập bằng cách sử dụng

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
4 hoặc
He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
5.

Ghi chú::

Truy cập các ký tự trong các chữ viết bằng cách sử dụng cú pháp

He drank some apple juice.
He drank some orange juice.
He drank some purple juice.
John Smith drank some apple juice.
John Smith then said hello to Jane Smith.
John Smith's wife greeted Robert Paulsen.
Robert Paulsen greeted the two .
5 đã được không dùng nữa trong Php 7.4. Điều này đã được gỡ bỏ trong Php 8.0.

Chuyển đổi thành chuỗi

Một giá trị có thể được chuyển đổi thành một chuỗi bằng cách sử dụng hàm

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
00 hoặc hàm strval (). Chuyển đổi chuỗi được tự động thực hiện trong phạm vi của một biểu thức trong đó cần một chuỗi. Điều này xảy ra khi sử dụng các hàm echo hoặc in hoặc khi một biến được so sánh với một chuỗi. Các phần về loại và loại tung hứng sẽ làm cho các phần sau hơn. Xem thêm hàm setType ().string using the
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
00 cast or the strval() function. String conversion is automatically done in the scope of an expression where a string is needed. This happens when using the echo or print functions, or when a variable is compared to a string. The sections on Types and Type Juggling will make the following clearer. See also the settype() function.

Giá trị bool

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
01 được chuyển đổi thành chuỗi
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
02. Bool
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
03 được chuyển đổi thành
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
04 (chuỗi trống). Điều này cho phép chuyển đổi qua lại giữa các giá trị bool và chuỗi.bool
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
01
value is converted to the string
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
02. bool
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
03
is converted to
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
04 (the empty string). This allows conversion back and forth between bool and string values.

Một int hoặc float được chuyển đổi thành một chuỗi biểu thị số bằng văn bản (bao gồm cả phần số mũ cho phao). Số điểm nổi có thể được chuyển đổi bằng ký hiệu hàm mũ (

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
05).int or float is converted to a string representing the number textually (including the exponent part for floats). Floating point numbers can be converted using exponential notation (
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
05).

Ghi chú::

Kể từ Php 8.0.0, ký tự điểm thập phân luôn là

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
06. Trước Php 8.0.0, ký tự điểm thập phân được xác định trong ngôn ngữ của tập lệnh (danh mục LC_Numeric). Xem hàm setlocale ().setlocale() function.

Các mảng luôn được chuyển đổi thành chuỗi

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
07; Bởi vì điều này, Echo và Print không thể tự mình hiển thị nội dung của một mảng. Để xem một yếu tố duy nhất, hãy sử dụng một công trình như
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
08. Xem bên dưới để biết các mẹo về xem toàn bộ nội dung.s are always converted to the string
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
07; because of this, echo and print can not by themselves show the contents of an array. To view a single element, use a construction such as
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
08. See below for tips on viewing the entire contents.

Để chuyển đổi các đối tượng thành chuỗi, phải sử dụng phương thức ma thuật __ToString.objects to string, the magic method __toString must be used.

Tài nguyên luôn được chuyển đổi thành các chuỗi với cấu trúc

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
09, trong đó
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
10 là số tài nguyên được gán cho tài nguyên của PHP khi chạy. Mặc dù cấu trúc chính xác của chuỗi này không nên dựa vào và có thể thay đổi, nhưng nó sẽ luôn là duy nhất cho một tài nguyên nhất định trong vòng đời của tập lệnh được thực thi (tức là yêu cầu web hoặc quy trình CLI) và sẽ không được sử dụng lại . Để có được loại tài nguyên, hãy sử dụng hàm get_resource_type ().s are always converted to strings with the structure
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
09, where
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
10 is the resource number assigned to the resource by PHP at runtime. While the exact structure of this string should not be relied on and is subject to change, it will always be unique for a given resource within the lifetime of a script being executed (ie a Web request or CLI process) and won't be reused. To get a resource's type, use the get_resource_type() function.

The character at index -2 is n.
Changing the character at index -3 to o gives strong.
6 luôn được chuyển đổi thành một chuỗi trống. is always converted to an empty string.

Như đã nêu ở trên, trực tiếp chuyển đổi một mảng, đối tượng hoặc tài nguyên thành một chuỗi không cung cấp bất kỳ thông tin hữu ích nào về giá trị ngoài loại của nó. Xem các hàm print_r () và var_dump () để biết các phương tiện hiệu quả hơn để kiểm tra nội dung của các loại này.array, object, or resource to a string does not provide any useful information about the value beyond its type. See the functions print_r() and var_dump() for more effective means of inspecting the contents of these types.

Hầu hết các giá trị PHP cũng có thể được chuyển đổi thành chuỗi để lưu trữ vĩnh viễn. Phương pháp này được gọi là tuần tự hóa và được thực hiện bởi hàm serialize ().strings for permanent storage. This method is called serialization, and is performed by the serialize() function.

Chi tiết về loại chuỗi

Chuỗi trong PHP được triển khai dưới dạng một mảng byte và số nguyên cho biết độ dài của bộ đệm. Nó không có thông tin về cách các byte đó dịch sang các ký tự, để lại nhiệm vụ đó cho lập trình viên. Không có giới hạn về các giá trị mà chuỗi có thể bao gồm; Cụ thể, các byte có giá trị

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
12 (nul nul byte) được cho phép ở bất cứ đâu trong chuỗi (tuy nhiên, một vài chức năng, cho biết trong hướng dẫn này không phải là an toàn nhị phân, có thể gửi các chuỗi cho các thư viện bỏ qua dữ liệu sau khi Nul byte.)string in PHP is implemented as an array of bytes and an integer indicating the length of the buffer. It has no information about how those bytes translate to characters, leaving that task to the programmer. There are no limitations on the values the string can be composed of; in particular, bytes with value
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
12 (“NUL bytes”) are allowed anywhere in the string (however, a few functions, said in this manual not to be “binary safe”, may hand off the strings to libraries that ignore data after a NUL byte.)

Bản chất này của loại chuỗi giải thích lý do tại sao không có loại BYTE riêng biệt trong các chuỗi PHP - các chuỗi đảm nhận vai trò này. Các chức năng trả về không có dữ liệu văn bản - ví dụ, dữ liệu tùy ý đọc từ ổ cắm mạng - vẫn sẽ trả về chuỗi.

Cho rằng PHP không ra lệnh cho một mã hóa cụ thể cho các chuỗi, người ta có thể tự hỏi làm thế nào các chữ cái được mã hóa. Chẳng hạn, chuỗi

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
13 tương đương với
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
14 (ISO-8859-1),
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
15 (Mẫu UTF-8, C),
PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
16 (Mẫu UTF-8, D) hoặc bất kỳ biểu diễn có thể nào khác? Câu trả lời là chuỗi sẽ được mã hóa theo bất kỳ thời trang nào được mã hóa trong tệp tập lệnh. Do đó, nếu tập lệnh được viết trong ISO-8859-1, chuỗi sẽ được mã hóa trong ISO-8859-1, v.v. Tuy nhiên, điều này không áp dụng nếu Zend Multibyte được bật; Trong trường hợp đó, tập lệnh có thể được viết trong một mã hóa tùy ý (được khai báo rõ ràng hoặc được phát hiện) và sau đó được chuyển đổi thành một mã hóa nội bộ nhất định, sau đó là mã hóa sẽ được sử dụng cho các chuỗi chữ. Lưu ý rằng có một số ràng buộc đối với việc mã hóa tập lệnh (hoặc trên mã hóa nội bộ, nên kích hoạt đa tế bào -1. Tuy nhiên, lưu ý rằng các mã hóa phụ thuộc trạng thái trong đó các giá trị byte giống nhau có thể được sử dụng ở trạng thái dịch chuyển ban đầu và không khởi đầu có thể có vấn đề.

Tất nhiên, để trở nên hữu ích, các chức năng hoạt động trên văn bản có thể phải đưa ra một số giả định về cách chuỗi được mã hóa. Thật không may, có nhiều biến thể về vấn đề này trong suốt các chức năng của PHP:

  • Một số chức năng cho rằng chuỗi được mã hóa trong một số (bất kỳ) mã hóa byte nào, nhưng chúng không cần phải giải thích các byte đó là ký tự cụ thể. Đây là trường hợp của, ví dụ, chuỗi con (), strpos (), strlen () hoặc strcmp (). Một cách khác để nghĩ về các chức năng này là hoạt động trên bộ đệm bộ nhớ, tức là, chúng hoạt động với các byte và độ lệch byte.substr(), strpos(), strlen() or strcmp(). Another way to think of these functions is that operate on memory buffers, i.e., they work with bytes and byte offsets.
  • Các chức năng khác được thông qua mã hóa của chuỗi, có thể chúng cũng cho rằng mặc định nếu không có thông tin nào được đưa ra. Đây là trường hợp của htmlentity () và phần lớn các chức năng trong phần mở rộng MBString.htmlentities() and the majority of the functions in the mbstring extension.
  • Những người khác sử dụng ngôn ngữ hiện tại (xem setlocale ()), nhưng hoạt động byte-by-byte. Đây là trường hợp của strcasecmp (), strtoupper () và ucfirst (). Điều này có nghĩa là chúng chỉ có thể được sử dụng với mã hóa một byte, miễn là mã hóa được khớp với địa phương. Chẳng hạn
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    17 có thể trả về
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    18 nếu locale được đặt chính xác và
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    19 được mã hóa với một byte duy nhất. Nếu nó được mã hóa trong UTF-8, kết quả chính xác sẽ không được trả về và chuỗi kết quả có thể hoặc không được trả về bị hỏng, tùy thuộc vào ngôn ngữ hiện tại.setlocale()), but operate byte-by-byte. This is the case of strcasecmp(), strtoupper() and ucfirst(). This means they can be used only with single-byte encodings, as long as the encoding is matched by the locale. For instance
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    17 may return
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    18 if the locale is correctly set and
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    19 is encoded with a single byte. If it is encoded in UTF-8, the correct result will not be returned and the resulting string may or may not be returned corrupted, depending on the current locale.
  • Cuối cùng, họ có thể chỉ cho rằng chuỗi đang sử dụng mã hóa cụ thể, thường là UTF-8. Đây là trường hợp của hầu hết các chức năng trong tiện ích mở rộng INTL và trong phần mở rộng PCRE (trong trường hợp cuối cùng, chỉ khi sử dụng công cụ sửa đổi
    PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
    
    20). Mặc dù điều này là do mục đích đặc biệt của chúng, hàm utf8_decode () giả định mã hóa UTF-8 và hàm utf8_encode () giả định mã hóa ISO-8859-1.utf8_decode() assumes a UTF-8 encoding and the function utf8_encode() assumes an ISO-8859-1 encoding.

Cuối cùng, điều này có nghĩa là viết các chương trình chính xác bằng cách sử dụng Unicode phụ thuộc vào việc tránh cẩn thận các chức năng sẽ không hoạt động và rất có thể sẽ làm hỏng dữ liệu và sử dụng thay vào đó các chức năng hoạt động chính xác, thường là từ các phần mở rộng INTL và MBString. Tuy nhiên, sử dụng các chức năng có thể xử lý mã hóa Unicode chỉ là khởi đầu. Bất kể các chức năng mà ngôn ngữ cung cấp, điều cần thiết là phải biết đặc tả Unicode. Chẳng hạn, một chương trình giả định chỉ có chữ hoa và chữ thường đang đưa ra một giả định sai.

John ¶

5 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
21

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
22

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
23

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
24

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
25

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
26

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
27

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
28

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
29

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
30

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
31

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
32

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
33

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
34

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
35

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
36

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
37

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
38

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
39

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
40

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
41

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
42

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
43

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
44

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
45

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
46

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
47

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
48

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
49

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

gtisza tại gmail dot com

10 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
51

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
52

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
53

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
54

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
55

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

rác tại iglou dot eu ¶

6 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
57

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
58

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
59

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
60

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
61

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
62

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
63

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

Ray.paseur đôi khi sử dụng gmail ¶

3 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
65

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
66

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

VSOEKDOG tại Gmail Dot Com ¶

3 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
68

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
69

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
70

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

VSOEKDOG tại Gmail Dot Com ¶

OG tại Gams Dot tại ¶

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
72

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
73

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
74

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
75

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

15 năm trước

6 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
77

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
78

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
79

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
80

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
81

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

Ray.paseur đôi khi sử dụng gmail ¶

3 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
83

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
84

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

VSOEKDOG tại Gmail Dot Com ¶

OG tại Gams Dot tại ¶

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
86

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
87

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

15 năm trước

Sideshowanthony tại googlemail dot com ¶

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
89

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
90

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
91

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
92

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
93

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
94

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
95

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
96

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
97

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

Lelon tại Lelon Dot Net

17 năm trước

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
99

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
00

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
01

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
02

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
03

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
04

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
05

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
06

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

Steve tại MrClay Dot org ¶

14 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
08

necrodust44 tại gmail dot com ¶

OG tại Gams Dot tại ¶

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
09

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
10

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
11

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

15 năm trước

6 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
13

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
14

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
15

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
16

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
17

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
18

Ray.paseur đôi khi sử dụng gmail ¶

3 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
19

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
20

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
21

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
22

VSOEKDOG tại Gmail Dot Com ¶

OG tại Gams Dot tại ¶

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
23

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
24

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

15 năm trước

5 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
26

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
27

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
28

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
29

gtisza tại gmail dot com

10 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
30

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
31

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
32

rác tại iglou dot eu ¶

3 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
33

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
34

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

VSOEKDOG tại Gmail Dot Com ¶

OG tại Gams Dot tại ¶

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
36

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
37

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
38

15 năm trước

5 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
39

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
40

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
41

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
42

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
43

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
44

gtisza tại gmail dot com

10 năm trước

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
45

array(2) {
  [0] =>
  string(11) "a
  b
    c"
  [1] =>
  string(5) "d e f"
}
46

PHP Parse error:  Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
50

Chuỗi với một ví dụ là gì?

Một chuỗi là bất kỳ loạt ký tự nào được giải thích theo nghĩa đen bởi một kịch bản.Ví dụ: "Hello World" và "LKJH019283" đều là những ví dụ về chuỗi.Trong lập trình máy tính, một chuỗi được gắn vào một biến như trong ví dụ dưới đây.any series of characters that are interpreted literally by a script. For example, "hello world" and "LKJH019283" are both examples of strings. In computer programming, a string is attached to a variable as shown in the example below.

Ý bạn là gì khi chuỗi trong PHP?

Thuật ngữ "chuỗi" đề cập đến một loạt các ký tự.PHP hỗ trợ một số loại dữ liệu, bao gồm cả chuỗi.Các ký tự chữ và số được cho phép trong các biến chuỗi.a series of characters. PHP supports a number of data types, including strings. Alphanumeric characters are allowed in string variables.

Chuỗi giải thích các loại chuỗi khác nhau trong PHP là gì?

Chuỗi PHP là một chuỗi các ký tự, tức là được sử dụng để lưu trữ và thao tác văn bản.PHP chỉ hỗ trợ bộ 256 ký tự và do đó nó không cung cấp hỗ trợ Unicode gốc.Có 4 cách để chỉ định một chuỗi theo nghĩa đen trong PHP.được trích dẫn đơn.Double Trích dẫn.a sequence of characters i.e., used to store and manipulate text. PHP supports only 256-character set and so that it does not offer native Unicode support. There are 4 ways to specify a string literal in PHP. single quoted. double quoted.