-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example of converting ==|!= to ===|!== #413
base: master
Are you sure you want to change the base?
Conversation
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: |
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)
<#413 (comment)>>,
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
<#413 (comment)>,
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. |
Craig, see if this works. $allow_view_other = ( ( $ALLOW_VIEW_OTHER ??= 'Y' ) === 'Y' ); if $ALLOW_VIEW_OTHER is undefined or null, assign 'Y'. In this case the default from default_config.php. Then see if it's === 'Y'
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.