Comparison between PHP and JS "problem solving" moduls (5) CODE
// Unlike JS, in PHP all variables are local in scope unless declared as global. so both languages are just opposite in declaring variables.
let x = 5;
let y = 3;
function sum() {
    console.log(x + y);
}
sum(); 
//outputs 8 in JavaScript,
$x = 3;
$y = 5;
function sum() {
    echo $x + $y;
}
sum();
//outputs error unless declaring variables
by Luka Khitaridze
2 years ago
PHP
JavaScript
Variables
0
Pro tip: use ```triple backticks around text``` to write in code fences