You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| <?php | |
| class Product extends Eloquent { | |
| public function categories() | |
| { | |
| return $this->belongsToMany('Category'); | |
| } | |
| } |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| <form data-abide> | |
| <div class="name-field"> | |
| <label>Your name <small>required</small></label> | |
| <input type="number" required pattern="[a-zA-Z]+"> | |
| <small class="error">Name is required and must be a string.</small> | |
| </div> | |
| <div class="email-field"> | |
| <label>Email <small>required</small></label> | |
| <input type="text" required pattern="email"> | |
| <small class="error">An email address is required.</small> |