php variables and strings
We use variables to store values and we use string variables to store the values that includes the characters. We can use the php string directly in our coding but it is more time consuming than saving the php strings into one variable and use it again and again. For example :
<?php$msg = "I love my country !";
Here, we store the string value in $msg variable. We can also concatenate two or more string variables. For example :
$msg = "I love my country";
$msg1 = "We should care our country.";
$msg2 = "We should follow the rules and regulations of the country !";
echo $msg . " ," . " " . $msg1 . " " ." and " . $msg2;
Here, we concatenate different-2 messages in one.
In PHP we have also some pre-defined string functions which is very useful to learn. For example :
(1) Strlen ( ) function which counts the characters in the string.
<?phpecho strlen("I love my country");
The output is : 17.
(2) Strpos ( ) function is to find the character in the string. It finds the length of the particular character.
echo strpos("I love my country","country");
The output is : 7 or sometime it will take the value of blanks, space or commas and soon.
Apart from these two functions strings contains several more functions to save your time.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.