Open bbannon opened 9 months ago
I don't think this actually correct as far as avoiding undefined vars.
I tried this script:
<?php
if ( $B === 1 ) {
echo "B is 1\n";
}
?>
And got this result with PHP 8.2:
PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3
What do you get for if ( $b !== 1 )
or
if ( $b === '1' )
On Tue, Sep 19, 2023 at 9:06 AM Craig Knudsen @.***> wrote:
I don't think this actually correct as far as avoiding undefined vars.
I tried this script:
<?php if ( $B === 1 ) { echo "B is 1\n"; } ?>
And got this result with PHP 8.2: PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3
— Reply to this email directly, view it on GitHub https://github.com/craigk5n/webcalendar/pull/413#issuecomment-1725834550, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ7GLV7ZEX6YRHOXST7Q5DX3GYIPANCNFSM6AAAAAA42XNW7Q . You are receiving this because you authored the thread.Message ID: @.***>
What do you get for if ( $b !== 1 ) or if ( $b === '1' ) … On Tue, Sep 19, 2023 at 9:06 AM Craig Knudsen @.> wrote: I don't think this actually correct as far as avoiding undefined vars. I tried this script: <?php if ( $B === 1 ) { echo "B is 1\n"; } ?> And got this result with PHP 8.2: PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3 — Reply to this email directly, view it on GitHub <#413 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ7GLV7ZEX6YRHOXST7Q5DX3GYIPANCNFSM6AAAAAA42XNW7Q . You are receiving this because you authored the thread.Message ID: @.>
I got undefined variable for both of these cases.
Well, that's annoying. All 3 work on my machine, and the documentation suggests it should work for everyone.
On Thu, Sep 21, 2023 at 9:10 PM Craig Knudsen @.***> wrote:
What do you get for if ( $b !== 1 ) or if ( $b === '1' ) … <#m-661119662859921926> On Tue, Sep 19, 2023 at 9:06 AM Craig Knudsen @.> wrote: I don't think this actually correct as far as avoiding undefined vars. I tried this script: And got this result with PHP 8.2: PHP Warning: Undefined variable $B in /var/www/html/webcalendar/test.php on line 3 — Reply to this email directly, view it on GitHub <#413 (comment) https://github.com/craigk5n/webcalendar/pull/413#issuecomment-1725834550>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ7GLV7ZEX6YRHOXST7Q5DX3GYIPANCNFSM6AAAAAA42XNW7Q https://github.com/notifications/unsubscribe-auth/AHJ7GLV7ZEX6YRHOXST7Q5DX3GYIPANCNFSM6AAAAAA42XNW7Q . You are receiving this because you authored the thread.Message ID: @.>
I got undefined variable for both of these cases.
— Reply to this email directly, view it on GitHub https://github.com/craigk5n/webcalendar/pull/413#issuecomment-1730742502, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ7GLRW6W36K646ZZPZIN3X3T6SDANCNFSM6AAAAAA42XNW7Q . You are receiving this because you authored the thread.Message ID: @.***>
Well, even if some form of '! empty()' is still required, everything I've read says it's better to use === | !== anyway.
why? because ! empty ( $x ) && $x == 'Y' can be shortened to $x === 'Y' without losing anything. as $x in $x === 'Y' can not be empty, null, undefined, not set, 'zebra' or anything else except 'Y'
Also, some examples of making changed lines comply with developers-guide as far as line length and spaces around ()s and such.