- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
You'd need to debug value of $var
on both setups and compare it. It's obvious that it will be different, and then based on result you can try to understand the root cause of difference. The simplest way to debug is to add var_dump($var);
before that if-elseif-else
statement.
IMO the root cause of your issue will be the use of the "Equal" comparator. PHP is a loosely typed language and using ==
(Equal) instead of ===
(Identical) allows PHP to automatically cast either value before making the comparison. This effect is compounded when a value is 0
or 1
because they will be interchanged with TRUE
& FALSE
so your initial intention to verify that the value of $var
is "1"
will become "is there a value in $var
?"
You can read more about Comparison Operators on the PHP docs.
In a case where you are using two different Operating Systems, I would imagine you are dealing with different default PHP Runtime Configurations. To verify this you can export the current configuration from each instance using the phpinfo() function and perform a Diff.
BTW, don't leave the function accessible for longer than you need it as this is a security risk.
Thank you for that clarification about the Equal vs Identical, it is very interesting that == is just TRUE or FALSE, in that situation. I've tried to redo the ifelse statement, and if I set the variable to
$var === '1'
, (with the single-quotes around the 1), I can get that part of the statement to work, but it seems that as soon as it decides it has determined which operation to do, it just breaks out of the if->ifelse->else statement completely, even though this statement is nested within afor
statement which is still counting and incrementing a variable.I must mention this code works fine (even if it's just deciding TRUE or FALSE and not actually verifying the value of $var), on my CentOS dev server. I will also note that my dev server has 'Thread Safety' off, and the AL2 system has it turned on. Could it be Thread Safety that is breaking out of the ifelse statement? The Dev server is also using php-fpm and AL2 is not; some other seemingly unrelated php modules -- bcmath, mcrypt, tidy -- are running on Dev but not on AL2 as well. Why would enabling php-tidy, for example, have any effect on the way PHP 7.3.29 handles an ifelse statement? I'm pretty sure it would not have an effect.
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 2 anni fa
This is the solution. I am doing an
array_column
on a column coming out of the database; but, the related table in the Prod database was one row shorter than the Dev database -- as was revealed to me by thevar_dump($var);
procedure. Suffice it to say, I am very glad my concerns about the PHP Runtime environment were unfounded.