Karl Karl - 5 months ago 13
PHP Question

CakePHP variable parsing change

I have a strange problem; I have a variable, as follows:

$postBSGlobal = $post['Post']['B/S']


Which, when debugged, correctly delivers

"B"


But, later on the value magically changes to

"1"


Without me manipulating the variable in any way.

I need the string-value for this statement:

if ($userId <> $post['Post']['OWNER'] && $postBSGlobal = 'B'){
echo "Dein Verdienst:";
};


Today my app is completely unusable due to this problem. Maybe the PHP-version on my managed server has changed? How can I prevent PHP from returning the "1"?

Answer

You used a single = instead of ==. Change it to:

$postBSGlobal == 'B'

Comments