Thursday 14 May 2009

Text

When they're used in computer programs, pieces of text are called strings. This is because they consist of individual characters, strung together. Strings can contain letters, numbers, punctuation, spaces, tabs, or any other characters. Some examples of strings are I would like 1 bowl of soup, and "Is it too hot?" he asked, and There's no spoon!. A string can even contain the contents of a binary file such as an image or a sound. The only limit to the length of a string in a PHP program is the amount of memory your computer has.
Defining Text StringsThere are a few ways to indicate a string in a PHP program. The simplest is to surround the string with single quotes:
print 'I would like a bowl of soup.'; print 'chicken'; print '06520'; print '"I am eating dinner," he growled.';
Since the string consists of everything inside the single quotes, that's what is printed:
I would like a bowl of soup.chicken06520"I am eating dinner," he growled.
The output of those four print statements appears all on one line. No linebreaks are added by print.[1]

Join Free Now : PHP Tutorial

No comments:

Post a Comment