mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-14 09:44:00 +02:00
Avoid comment misunderstanding
Old: `$a = 3; return ($a == 3) ? true : false; // Will return true or false if $a == 3` New: `$a = 3; return ($a == 3) ? true : false; // Will return true if $a == 3 or false` help us to avoid misunderstanding of the comment
This commit is contained in:
@@ -367,12 +367,12 @@ would be.
|
|||||||
{% highlight php %}
|
{% highlight php %}
|
||||||
<?php
|
<?php
|
||||||
$a = 3;
|
$a = 3;
|
||||||
return ($a == 3) ? true : false; // Will return true or false if $a == 3
|
return ($a == 3) ? true : false; // Will return true if $a == 3 or false
|
||||||
|
|
||||||
// vs
|
// vs
|
||||||
|
|
||||||
$a = 3;
|
$a = 3;
|
||||||
return $a == 3; // Will return true or false if $a == 3
|
return $a == 3; // Will return true if $a == 3 or false
|
||||||
|
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
@@ -386,12 +386,12 @@ within blocks of statements. An example of when there is no requirement to use b
|
|||||||
{% highlight php %}
|
{% highlight php %}
|
||||||
<?php
|
<?php
|
||||||
$a = 3;
|
$a = 3;
|
||||||
return ($a == 3) ? "yay" : "nope"; // return yay or nope if $a == 3
|
return ($a == 3) ? "yay" : "nope"; // return yay if $a == 3 or nope
|
||||||
|
|
||||||
// vs
|
// vs
|
||||||
|
|
||||||
$a = 3;
|
$a = 3;
|
||||||
return $a == 3 ? "yay" : "nope"; // return yay or nope if $a == 3
|
return $a == 3 ? "yay" : "nope"; // return yay if $a == 3 or nope
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
Bracketing also affords us the capability of creating unions within a statement block where the block will be checked
|
Bracketing also affords us the capability of creating unions within a statement block where the block will be checked
|
||||||
|
Reference in New Issue
Block a user