asked in PHP by (6.6k points) recategorized by
0 like 0 dislike
5 views

According to the most programming languages scope rules, I can access variables that are defined outside of functions inside them, but in PHP for access to outside variable in function need bind (poin to variable) it with help key word "global". However, when I do same for outside constant, this doesn't work. Why doesn't this work? How to inside function get access to constant, what did be declare outside, in PHP?


php access global variable in function
php access global constant in function
php global constant in function

Your answer

Try to answer the question as detailed as possible.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

0 like 0 dislike
answered by (6.6k points)
It is not working because for getting access to constant don't need bind it via key word "global" in function in PHP. Key word "global" used only for outside variables. Access to outside constants in functions there have default. Just use outside constant in functions without key word "global".

Related questions

0 like 0 dislike
1 answer 42 views
0 like 0 dislike
1 answer 9 views
0 like 0 dislike
1 answer 28 views
0 like 0 dislike
1 answer 48 views
0 like 0 dislike
1 answer 27 views
0 like 0 dislike
1 answer 33 views
0 like 0 dislike
1 answer 8 views
0 like 0 dislike
1 answer 25 views
0 like 0 dislike
1 answer 18 views
...