0
A string
Can anyone explain to me what a string in php is and a very good example on how to use them.
3 odpowiedzi
+ 5
sean Seeing your problem was resolved already it would be great if you can mark the answer that you find useful to encourage the community to help each other. 😉
+ 2
a string is a sequence of characters.
example
$string = "Hello World";
$string = "1st";
etc
You use them whenever you want to store and later retrieve or manipulate a sequence of characters.
Like
$firstName = "Bob";
echo $firstName;
There are more ways to use them than the mind can conceive of.
Now, "10" is a string but because it contains only numeric values php will interpret it as a number.
$string = "10";
$int = 10;
$int == $string returns true.
$int === $strong returns false
== merely compares value and php interprets string 10 as an int.
=== compared type as well as value and one is a string the other an int so it fails.
+ 1
Oh ok thanks