Strings in PHP

What we know about Strings in Java, Strings in PHP also mean the same. We can say a String to be a sequence of characters. A simple PHP String declaration looks like:

However, there is a slight difference between specifying a String value in double quotes and a String value in single quotes. Double quotes to the String value provides an additional capability to interpret certain character sequences, which means that a PHP variable when present in a String value, would get resolved when echoed, while the same String value defined with single quotes would display the variable name as it is, without substituting it with the current value. For example, try understanding the below code snippet.

The above PHP when executed, produces the following output:

This is what you most importantly need to know about Strings in PHP. Apart from this, there are several pre-defined String functions PHP provides us with. Below is the PHP snippet that demonstrates the usage of few of the pre-defined String functions in PHP.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.