mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-28 07:40:03 +02:00
Update The-Basics.md
if/else statements can't be used inside class definition, just inside class methods. This may confuse beginners.
This commit is contained in:
committed by
GitHub
parent
2080260c85
commit
ed0063cafd
@@ -42,7 +42,7 @@ if (strpos('testing', 'test') !== false) { // true, as strict comparison was
|
||||
|
||||
### If statements
|
||||
|
||||
While using 'if/else' statements within a function or class, there is a common misconception that 'else' must be used
|
||||
While using 'if/else' statements within a function or class method, there is a common misconception that 'else' must be used
|
||||
in conjunction to declare potential outcomes. However if the outcome is to define the return value, 'else' is not
|
||||
necessary as 'return' will end the function, causing 'else' to become moot.
|
||||
|
||||
|
Reference in New Issue
Block a user