Hello. Please tell me if I am right. Interested in more PHP, is it possible to do so, are there any pitfalls.
Variable in JS need to declare
var a = "1"; a += 1; alert(a); // '11' This will not work
a += 1; alert(a); And everything works in PHP
$a .= 1; echo $a; // '1' JS does not work
var a = '1'; if (a == '0') {b = '3';} alert(b); So show that the variable does not exist.
var a = '1'; if (a == '0') {var b = '3';} alert(b); // undefined I declare a variable before if
var a = '1', b = ''; if (a == '0') {b = '3';} alert(b); // '' But it works
var a = '1'; if (a == '1') {var b = '3';} alert(b); // '3' And everything works in PHP
$a = '1'; if ($a == '1') {$b = '3';} echo $b; // '3' And when the variable is not declared, an empty value is returned, not undefined.
$a = '1'; if ($a == '0') {$b = '3';} if ($b == '') echo "Hellow"; // "Hellow"
if (a == '0') {b = '3';}that is, compare with zero, althoughadeclared equal to 1 ..... and in PHPif ($a == '1') {$b = '3';}while$a = 1;........ but after all in js if to compare with 1 then thealertwill output 3 as in PHP ....... in the first example withvar a = "1";also in js you have one written in PHP and another ..... but if you write$a = "1"; $a .= 1; echo $a;$a = "1"; $a .= 1; echo $a;also bring11.......... or so necessary? - Alexey Shimanskyif ($b == '') echo "Hellow"; // "Hellow"if ($b == '') echo "Hellow"; // "Hellow"here isundefined, just need to check === it checks the type - L. Vadim