General discussion
what is the difference in these commands in PHP ?

I started learning php and came across a strange result in the same commands. Where is the difference?5d6957e99bbad

I started learning php and came across a strange result in the same commands. Where is the difference?![5d6957e99bbad](serve/attachment&path=5d6957e99bbad)
edited Aug 30 at 6:07 pm

By default, when you are inside a function, you do not have access to the outer variables. If you want your function to have access to an outer variable, you have to declare it as global, from inside the function.

But note that using global variables is not a good practice - with it, your function is not independent anymore.

About variable scopes and functions:

https://www.php.net/manual/en/language.variables.php

Kind regards, Andy

By default, when you are inside a function, you do not have access to the outer variables. If you want your function to have access to an outer variable, you have to declare it as global, from inside the function. But note that using global variables is not a good practice - with it, your function is not independent anymore. **About variable scopes and functions:** https://www.php.net/manual/en/language.variables.php Kind regards, Andy

42 years old and still not smarter lol

MyGitHub: https://github.com/WebCrew

CrazyMates Homepage: https://crazymates.de/Crazymate

edited Aug 30 at 6:19 pm

Youre welcome smile

Youre welcome :)

42 years old and still not smarter lol

MyGitHub: https://github.com/WebCrew

CrazyMates Homepage: https://crazymates.de/Crazymate

34
3
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft