[pmwiki-devel] PHP 8 undefined variables
Petko Yotov
5ko at 5ko.fr
Mon Apr 15 01:49:42 PDT 2024
On 15/04/2024 10:41, Simon wrote:
> In a recipe I have a statement
> \SDV($TotalCounterEnableGEOIP, 0); // default 0
>
> This sets the variable "$TotalCounterEnableGEOIP" or at least I assume
> it does.
>
> Further on I use the variable in the statement
> if ($TotalCounterEnableGeoIP == 1) {
>
> but PHP tells me
> Undefined variable $TotalCounterEnableGeoIP in
> D:\Home\KiwiWiki\pmwiki\cookbook\totalcounter.php on line 632
Are both statements in the same scope?
If the SDV() call is directly in the PHP file, and the conditional is in
a function, you need to have a declaration in the function before you
check the value:
global $TotalCounterEnableGeoIP;
If they are in different functions, you need to have the global
declaration in both functions.
Petko
More information about the pmwiki-devel
mailing list