QUOTE(kailoonthedog @ Nov 6 2011, 01:11 AM)
For example,
CODE
#include <iostream>
void output(){
std::cout << var;
}
int main(){
int var = 111;
output();
return 0;
}
vs
CODE
<?php
function output(){
echo $var;
}
function main(){
$var = 111;
}
main();
output();
?>
In the c++ code, obviously it won't even compile because variable var has not been initialized yet. If you throw it below main, then it'll still won't compile since there is no function called output.
It gives you a feel of encapsulation, even though you're still coding in procedural style.
Meanwhile, in the PHP code, it will run no matter how you change the orders of the functions.
Another difference would be adding several variables with arrays into a bigger array. How to do that in c++(not that we can't, but we need more work to do it as compared with PHP).
In php, its relatively easy.
And quite a lot of other things as well, such as the question that you just asked me. We don't handle the internals in PHP(unless you're going hardcore), while you have to go deeper in c++(pointers).