Re: setting the same value to multiple variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



charles stuart wrote:
if ( 1 == 1 )

^^ what is the point of this?

{
$goodToGo = 0; $errorArray[] = "You must declare some goals on Activity 1.";

// this block of code does not set each variable to "class=\"errorHere\"";

$readingGoalsEnjoymentLabelClass && $readingGoalsInformationLabelClass && $readingGoalsAlphabeticLabelClass && $readingGoalsPrintLabelClass && $readingGoalsPhonologicalLabelClass && $readingGoalsPhoneticLabelClass && $readingGoalsComprehensionLabelClass && $readingGoalsVocabularyLabelClass && $readingGoalsInstructionsLabelClass && $readingGoalsCriticalLabelClass && $readingGoalsCommunicateLabelClass = "class=\"errorHere\"";
}

While this seems like excessively ugly code (have you considered an array? what is the point of all those variables if they all hold the same value?), replace all of those '&&' with '=' and you will be fine. PHP evaluates right-to-left and the result of an assignment is the value that was assigned, so that will work.

--
Jasper Bryant-Greene
General Manager
Album Limited

http://www.album.co.nz/     0800 4 ALBUM
jasper@xxxxxxxxxxx          021 708 334

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux