| Also known as a literal
or literals, a literal string is a series of
characters that are enclosed in
quotes or
single quotes depending on the programming language or command
line you're using. When a string of characters is treated as literal
the programming language or command will not try to interpret
anything within the string until it encounters the next quote or
single quote. For example, in Perl
you'd use the below command to print: Hello World!
print "Hello World!";
However, if you wanted to print a quote within the string your
program would generate an error because it would not know where the
string starts and ends. Therefore you'd need to use an
escape character for each quote as shown
below.
print "I said \"Hello World!\"";
However, if the string was treated as a literal string as shown
below you would not need to escape any special programming or
command line character except of course the single quote.
print 'I said "Hello World!"';
Also see: Machine language,
Programming
definitions, Variable
|