Skip to content

Commit 0035810

Browse files
authored
Fix Invalid Code
The "Avoid Side Effects" section's "Bad" code block is actually invalid code, `splitIntoFirstAndLastName()` will throw a notice of `Undefined variable`. We need a `$global` here. I'm all for competing against code that people may have but there is no point comparing code that doesn't work in the first place, it's out of the bounds of this document.
1 parent 80097dd commit 0035810

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ than the vast majority of other programmers.
612612
$name = 'Ryan McDermott';
613613

614614
function splitIntoFirstAndLastName() {
615+
global $name;
616+
615617
$name = preg_split('/ /', $name);
616618
}
617619

0 commit comments

Comments
 (0)