Previous | Home | Next |
Strings
A string is a combination of letters, numbers, special characters and arithmetic values or individuals. First of all, we have to create string like a variable. There are two procedure to use string in php:
- You can store string in a function.
- You can store string in a variable.
Example: (Sample example)
<html> <head> <title>strings in PHP</title> </head> <body> <?php $myString = "This is a string..."; echo "Hello World....!!!!<br/>"; echo $myString; ?> </body> </html>
Output:

Single Quotes: This is the simplest way to create strings. It works on server easier and faster. There is no need to read whole string.
Example:
<html> <head> <title>single quotes in PHP</title> </head> <body> <?php $myString = 'Hello World....!!!!'; echo 'This is a string<br/>' . $myString ; ?> </body> </html>
Output:

Double Quotes: In Double Quotes, You can insert variables directly within the text of the string. The variables were automatically detected and concatenated with the text.
Example:
<html> <head> <title>double quotes in PHP</title> </head> <body> <?php $myString = "Hello World....!!!!"; $symbol = "@"; echo "$myString<br/>"; echo "This is Arun Kumar $symbol abc PVT. Ltd."; ?> </body> </html>
Output:

Previous | Home | Next |