Complete tutorial for String in PHP

What is String?

A PHP string is a collection of characters that can be used to save and manipulate text. PHP only supports a 256-character set, hence it doesn’t support Unicode natively.

The term “string” refers to a group of characters. PHP supports a number of data types, including strings.

Alphanumeric characters are allowed in string variables. When these conditions are met, strings are generated.

  • You create a variable and assign it to string characters.
  • With the echo statement, you can use PHP Strings directly.
  • String functions in PHP are language constructs that aid in the capturing of words.
  • Understanding how PHP strings work and manipulating them can help you become a more successful and productive developer.

In PHP, there are four different ways to specify a string literal.

  1. single quoted
  2. double quoted
  3. heredoc syntax
  4. newdoc syntax (since PHP 5.3)
Tagged : / / / / / /

Tutorial for String operators

What is String operators?

There are two string operators available. The usage of numerical numbers might lead to unexpected outcomes:

  1. The PHP operator (.) is also known as the concatenation operator. It joins separate threads together.
  2. The PHP operator (.=) is also known as the combined assignment operator. It connects the argument to the one on the right page, on the left.
  • Operator Name Example Result
  • Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2
  • .= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1

Example:-

Output:-

Tagged : / / / / / / /