PHP String functions


Welcome to all our readers on our website at As you all know that here on our website we will provide you lots of information related to the latest and newly introduced technology which help you to get updated with the latest tech. Here you will get all the useful information which is required in this tech world. As you know technology is one of the trending part in this world. So, here again we came up with a latest and new tech information which is related to the process of creating PHP String and String Manipulation . With the help of this article you will get to know the complete process of how to create PHP String and String Manipulation in a step by step manner. So, simply have a look to this article and grab all the useful information which is going to be very helpful for you.

Strings can be seen as a stream of characters. For example, ‘T’ is a character and ‘Tutorialpath’ is a string. We have learned about basics of string data type in PHP in PHP | Data types and Variables. In this article we will discuss about strings in details. Every thing inside quotes , single (‘ ‘) and double (” “) in PHP is treated as a string.

Creating Strings

There are two ways of creating strings in PHP:

  1. Single-quote strings: This type of strings does not processes special characters inside quotes.



    2. Double-quote strings : Unlike single-quote strings, double-quote strings in PHP is capable of processing special characters.



  • In the above program we can see that the double-quote strings is processing the special characters according the their properties.
  • The ‘\n’ character is not printed and is considered as a new-line. Also instead of the variable name $site, “Tutorialpath” is printed.

–> PHP treats everything inside double quotes(” “) as Strings.

–> In this article, we will learn about the working of the various PHP string functions and how to implement them along with some special properties of strings. Unlike other data types like integers, doubles etc.

–> Strings do not have any fix limits or ranges. It can extend to any length as long as it is within the quotes.




Some of the important and frequently used special characters that are used with double-quoted strings are explained below:

  • The character beginning with a backslash(“\”) are treated as escape sequences and are replaced with special characters. Here are few important escape sequences.
    1. “\n” is replaced by a new line
    2. “\t” is replaced by a tab space
    3. “\$” is replaced by a dollar sign
    4. “\r” is replaced by a carriage return
    5. “\\” is replaced by a backslash
    6. “\”” is replaced by a double quote
    7. “\’” is replaced by a single quote
  • The string starting with a dollar sign(“$”) are treated as variables and are replaced with the content of the variables.


String Functions


Built-in String functions

Built-in functions in PHP are some existing library functions which can be used directly in our programs making an appropriate call to them. Below are some important built-in string functions that we use in our daily and regular programs:

The PHP String function are part of the PHP core.

  1. strlen() function: This function is used to find the length of a string. This function accepts the string as argument and return the length or number of characters in the string.


2. strrev() function: This function is used to reverse a string. This function accepts a string as argument and returns its reversed string.


3. strpos() function: This function takes two string arguments and if the second string is present in the first one, it will return the starting position of the string otherwise returns FALSE.



So, hopefully we had shared all the basic steps which help you to PHP String Function . If you are using any of the above given browser and the steps helps you to enable or disable the JavaScript then simply share this article with others and also tell us by dropping a comment in the comment section below so that we get to know how helpful this article is for you all.

Leave a Reply

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