Horje Website
PHP Global Keyword – Learn Global keyword – PHP Code

PHP Global Keyword – Learn Global keyword

PHP Global Keyword - Learn Global keyword - PHP Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>PHP Global Keyword</title>
  5. </head>
  6. <body>
  7. <?php
  8. $greet = "Hello World!";
  9. // Defining function
  10. function test(){
  11. global $greet;
  12. echo '<p>$greet inside function is: ' . $greet . '</p>';
  13. }
  14. test();
  15. echo '<p>$greet outside of function is: ' . $greet . '</p>';
  16. // Assign a new value to variable
  17. $greet = "Goodbye";
  18. test();
  19. echo '<p>$greet outside of function is: ' . $greet . '</p>';
  20. ?>
  21. </body>
  22. </html>



Try Your Self ->



Published:
September 25, 2020
Author:
admin
Category:
PHP Basic, PHP Source Code
Views:
16

This article was posted in PHP Basic, PHP Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2023