PHP Weird Syntax – What is it called?

I’ve been following a video series on how to make a CMS with CodeIgniter and I’ve come across a weird construct. I’d just like to find out what it’s called so I can read up on it some more. In the video, the speaker gives this code

public function edit($id == NULL)
   $id == NULL || $this->data['user'] = $this->user_m->get($id);

He says, if the caller passes no id, then the $id will set to null, if an $id is passed, the user will be retrieved from the database and saved in the data array.

Thing is, this is a conditional statement, but it’s not inside an if or while or something like that. I’ve never seen that before. I’ve searched for inline or, conditional outside a loop/if statement, weird syntax with no success. Like I said, I’d like to read up more about it and find out whether it’s a general PHP feature or CI-specific.


Source: syntax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.