Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Variables Scope

file name myServices.php

<?php
   $gender = 'MALE';
?>

in another file lets say file.php

    include "myServices.php"

    $name = 'SAM';
    $age  = '23';
?>

<!--after some more HTML code-->
<?php

    $gender = 'FEMALE';        
    $name = 'ELENA';
    //Question:
    //In the above statements are there new variables created or the 
    //previous variables are reassigned new values

?>
like image 525
Moon Avatar asked Jul 02 '26 06:07

Moon


1 Answers

The previous variables are reassigned new values.

like image 194
Codeacula Avatar answered Jul 03 '26 18:07

Codeacula



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!