[wp-hackers] usage of single quotes and double quotes in PHP

aditya sharma sharmaaditya333 at gmail.com
Fri Mar 4 09:55:16 UTC 2011


To declare a variable it is sufficient to choose a name, through which the
variable will be identified, and then initialize it. It is not necessary, as
it happens for other programming languages, to declare the type of the
variable. PHP is able to deduce the type of a variable from the value with
which it has been initialized. For instance, if we write

  $var1 = 7;

PHP will create a variable of integer type with the name ' *$var1* ' and
store the value of *7* in it.

If instead we write

  $var2 = "This is a variable";

PHP will create a variable of string type named ' *$var2* ' and store the
value "*This is a variable*" in it.

The type of a variable indicates what kind of data the variable will store.
The concept of datatypes is particularly important, not only in PHP, but in
all programming languages.



Warm Regards
Aditya Sharma




On Fri, Mar 4, 2011 at 12:15 AM, Dion Hulse (dd32) <wordpress at dd32.id.au>wrote:

> Yes, ' is better/greater than "
> Except when the string will include the ' character, in which case, just
> use
> " anyway.
> IE. "This is a 'test' string." vs 'This is a \'test\' string.' the first is
> more readable.
>
> On 4 March 2011 10:48, Satish Gandham <satish.iitg at gmail.com> wrote:
>
> > *Dion Hulse,
> >
> > You mean its better to use ' than ", right?
> >
> > *
> >
> > In WordPress, ' > " unless the string is going to contain
> >
> >
> >
> >
> > Regards
> > Satish Gandham
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list