Home » PHP Tutorial » PHP String Example – @CodeMirch

PHP String Example – @CodeMirch

What is a String in PHP ?

In this chapter we are given examples of PHP String. The String is a series of characters. For Example, We defined simple String – “Hello PHP String“.

Example 1 :


$str_example = “This is a basic PHP Code”;

Echo $str_example;


PHP String Function :

In this section We will cover up String Function for all that they can easily understand the basic function.Lets See Our Example

Php string replace – str_replace() Function

This Function is used for replacing the String

Example 2 :

$str_replace = str_replace(“Welcome”,”Text”,”This is a Welcome Message”);

Echo $str_replace;


Here We can see Welcome will be changed after the execution the PHP Code. The Output will show “This is a Text Message” in lieu of the – “This is a Welcome Message”.

“Welcome” will be omitted and “Text” Will Come.

PHP strlen() Function Example

This function is used for length of string.Lets Check Our Example.

Php string length


$str_len = “This is a PHP Example“;

Echo strlen($str_len);


Here We can easily find the output of String Length.

PHP String concatenation Example :

The concatenation means in PHP  that two strings add with the help of dot operator.

Dot Operator : Concatenate Two or More String.

Example :


$str = “S +”;

$str1 = “W”;

Echo $str.$str1;


Here The Output will be shown –  “S+W”

Watch Our PHP Tutorial Video :

, , , , ,


  1. Animesh says:

    Sir, I Am realy helpfulfor this tutorial Witch you have shared “PHP String Example”. This is a very easy tutorial for us. Thank you so much .. @Codemich is best for my reviews.Thanks to to help me.

  2. admin says:

    Thanks Animesh You are sharing your thought.We Welcome Your Appriciation.Please Share our Free Web Development Tutorial With your friends .
    Join @Codemirch
    Free Web Development Tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *