[pmwiki-devel] PHP 8 undefined variables

Simon nzskiwi at gmail.com
Sat Apr 20 15:18:53 PDT 2024


Thanks for this, you are of course correct, and as always very helpful.

I regret to say the error was mine, and was simply due to case sensitivity,
viz
$TotalCounterEnableG*EO*IP <> $TotalCounterEnableG*eo*IP

Simon


On Mon, 15 Apr 2024 at 20:49, Petko Yotov <5ko at 5ko.fr> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20240421/f52cd481/attachment.html>


More information about the pmwiki-devel mailing list