A string is just a sequence of characters. In PHP, strings are enclosed in quotes such as ” or ‘.
Strings can be printed or assigned to variables. Let’s take a look at an example.
<?php $my_string_variable = "This is a string" . ' and so is this'; print $my_string_variable; print "\nHere's another string"; ?>
The output of this code is:
This is a string and so is this
Here’s another string
The code above makes use of two new characters: ‘\n’ and ‘.’. ‘.’ concatenates two strings. Concatenation just means it “glues” together two strings. The ‘\n’ character means to continue the output on the next line. Literally it means, “new” line.
Moving on. strlen() is a tool you need. It is probably the most important “string” function. It simply tells you how many characters are in a string. print strlen(“hi”); would print 2 to the screen.
For a bit more about strings check out the PHP instr() tutorial.













is that it 4 lessons? will there be more?
hey.. i really like your tutorials.. Is this the end ? please add more and more about PHP… Kudos..
Thanks guys. Sounds like I need to be making a lesson 5 soon. I’ll start working on it.