I was just debuging some code, and found that
$id = null;
$field = $id === null ? true : false;
$field = $id ? true : false;
Both should set $field to TRUE value. However for some reason it does not work as intended. First one returns true, other one returns false.
Edit1: I accidentaly mistook things when writing question. It should be why its different.
Edit2: I ask my question since this behaviour is different on 2 different servers. 2nd Example is expected to return True, but somehow it does not return true on one of my servers.
Edit3: Here is the real code. Its class/ObjectModel.php in Prestashop 1.5
/* Copy the field, or the default language field if it's both required and empty */
if ((!$this->id_lang AND isset($this->{$field}[$id_language]) AND !empty($this->{$field}[$id_language]))
OR ($this->id_lang AND isset($this->$field) AND !empty($this->$field)))
$fields[$id_language][$field] = $this->id_lang === null ? pSQL($this->$field) : pSQL($this->{$field}[$id_language]);
elseif (in_array($field, $this->fieldsRequiredLang))
$fields[$id_language][$field] = $this->id_lang === null ? pSQL($this->$field) : pSQL($this->{$field}[Configuration::get('PS_LANG_DEFAULT')]);
else
$fields[$id_language][$field] = '';
The expected behaveior (that is true on most servers) is if $this->id_lang is set to null then $this->$field should be used instead of $this->$field[$id_language]. However, on my server set on CentOS machine this behaviour differ and when value is set to null it gets $this->$field[$id_language] as value.
$field = $id ? true : false;to be true?$field = $id === nullis enough :)