[KLUG Members] PHP strict.

bill members@kalamazoolinux.org
Sat, 03 Aug 2002 13:44:47 -0400


Short answer, no.

Variables are treated as strings by default.  It is not necessary to define them
in advance.  You can test values for whatever type you want, and PHP will handle
values however you want.

For example:

$var=1;
$anothervar=2;

$myvar = $var + $anothervar;
// myvar will be 3;  because this is math (+), it assumes numbers

$myvar = $var . $anothervar;
$myvar will be "12";  // because this is concantenation (.), it assumes
characters,
// So, this is the string "1" with the string "2" appended.

kind regards,

bill

Richard Vincent wrote:

> Hello,
>
> I’m in the process of learning PHP and I have a quick question. Is there a way
> to use strict variable declaration inside of PHP? … Because right now I get an
> error when I try and declare my variables at the top of my programs….
>
> Thank You
>
> Richard Vincent
>