String data type

PHP string is used to manipulate and store text . String varible contains characters.you can use string variable directly in function or stored variabes after use . The string functions are part of the PHP core. The single quotes, double quotes, and escape sequences can to use PHP string varible.

Php String Syntax

Variable ='string';

Below example first storing it into a variable and second case we print string through echo statement.

Php String Example


<?php
$my_first_string = "Tutorialsscripts!";
echo 'TutorialsScripts!';
echo "<br>";
echo $my_first_string;
?>

out put:

TutorialsScripts!
TutorialsScripts!

In the above example the first string will be stored into the variable $my_first_string . The second will be used in 'echo' statement and not be stored variable.if you need single code to output you use backslash front of single single-quote.

Example :

<?php
echo 'TutorialsScripts- It\'s Neat!';
?>

PHP String Functions

Here are the some of PHP string functions





Content