Sunday, 15 November 2009

Double and Sinlgle quotes

Difference between enclosing strings in " " and ' ' is :

There are two differences between double-quoted strings and single-quoted strings. The first difference is that scalar variables are replaced by their values in double-quoted strings but not in single-quoted strings. The following is an example:

$string = "a string";
$text = "This is $string"; # becomes "This is a string"
$text = 'This is $string'; # remains 'This is $string'

The second difference is that the backslash character, \, does not have a special meaning in single-quoted strings.

No comments:

Post a Comment

Tweets by @sriramperumalla