Exécuter
❯
Exécuter le code
Ctrl+Alt+R
Changer d'orientation
Ctrl+Alt+O
Changer de thème
Ctrl+Alt+D
<!DOCTYPE html> <html> <body> <h2>Portée locale</h2> <?php function myTest() { $x = 5; // portée locale echo "Variable x inside function is: $x<br>"; } myTest(); // utiliser x en dehors de la fonction ne fonctionnera pas echo "La variable x en dehors de la fonction est : $x"; ?> </body> </html>
Portée locale
Variable x à l'intérieur de la fonction est : 5
Variable x en dehors de la fonction est :