0
php
<?php $name = 'David'; function getName() { global $name; echo $name; } getName(); ?> // why would you use so many commands to generate one name
2 Answers
+ 3
You could just use echo âDavidâ; inside the php tags to get the same results
+ 2
if you don't use function insside php then you can print using echo "David",
but here you have used function() so inside function you need global to get $name from outside the function then print echo $name
and getName(); runs the function outside the function