I saw the following lines of code, and I know what they do, but I donβt know how the second line works (and therefore how to apply it to another situation).
$user = User::model()->findByPk(123);
empty($user->profile) and $user->profile = new Profile();
The code tries to find the user from the database, and if there is no profile, a new one is created for use later.
I also saw the code before something like the following:
$variable1 = $variable2 = $variable3;
He did something more complicated than just assigning the three things the same, but I canβt find this type of thing to find out any information about this, let alone find the source code that I came across. I think he initially had an "and." Does anyone know how to look for code that has more than one equal sign that was not just an if statement?
Sorry for the two questions in one (and vague in this) and the terrible headline (I will correct this when I find out what these names are, if it is something like a shadowy statement)).
source
share