PHP Strings


PHP Strings is a sequence of characters used to store and manage text, and PHP only supports a set of 256 characters and does not offer traditional Unicode support. There are four ways to define a real thread in PHP.

There are 4 ways to define a real thread in PHP.

  • single quoted
  • quoted twice
  • heredoc syntax
  • new syntax (from PHP 5.3)

One Quote

We can create a thread in PHP by entering text in a single dimension, and it's an easy way to specify a thread in PHP.

By specifying one realistic scale, run it with a backslash (\) and specify a real backslash (\) using a double backslash (\\). All other retrospective situations, such as \ r or \ n, will be excluded in the same way as defined instead of having a special meaning.

For example

Following are some examples given to understand the one PHP String quoted in the best way:

Example 1

<?php $site = 'Welcome to knowledge 2life'; echo $site; ?>  

output:

Welcome to knowledge 2life  

Quoted twice

In PHP, we can specify a thread by inserting text within the double standard. But escape, and flexibility sequences will be translated using dual PHP cables.

Example 1

<? php $site = "knowledge 2life"; echo "Welcome to $site"; ?>

output:

Welcome to knowledge 2life  

Heredoc

Heredoc syntax (<<<) is the third method of wire separation. In the Heredoc syntax, the identifier is given after this heredoc operator <<<, and soon a new line begins to be written in any text. To close the quotation, the string follows them and is given the same direction. This lock indicator should start on a new line without white space or tab.

Valid Example

<? php     $ str = <<< Idemo It is a valid example Idemo; // Valid code such as white space or tab is invalid before closing the cursor echo $ str; ?>

Release:

It is a valid example