Last active
December 3, 2017 03:05
-
-
Save joaofnds/c3567936e20312737ddda86e8e1811ee to your computer and use it in GitHub Desktop.
Explanations here: https://www.youtube.com/watch?v=EGdjnu1NrZA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//1) Preferred | |
"text {$array['name']} more text"; // associative single | |
"text $array[2] more text"; // numeric single | |
"text $object->name $object->price more text"; // property | |
//2) Valid alternatives | |
"text $array[name] more text"; // associative single | |
"text {$array[2]} more text"; // numeric single | |
"text {$object->name} {$object->price} more text"; // property | |
//3) The only way | |
"text {$object->buy()} more text"; // method call | |
"text {$array['release year']} more text"; // associative single with space | |
"text {$array[1][3]} more text"; // multi dimensional numeric | |
"text {$array['random'][3]} more text"; // multi dimensional associative | |
"text ".add(5,10)." more text"; // functions | |
"text ".ANSWER." more text"; // constants | |
//4) Invalid | |
$array[name]; // Single associative, outside of double quotes | |
"text {ANSWER} more text"; // constant | |
"text {add(5,10)} more text"; // function | |
"text {$object->name $object->price} more text"; // properties | |
"text $object->buy() more text"; // method call | |
"text $array[random][5] more text"; // associative multi | |
"text {$array[random][5]} more text"; // associative multi | |
"text $array['release year'] more text"; // associative single with space | |
"text $array[1][3] more text"; // numeric multi | |
"text {$array{1}{3}} more text"; // numeric multi | |
"text {$array{'actor'}} more text"; // associative single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment