Last active
June 15, 2018 09:55
-
-
Save xeoncross/049a1c4ba19d0120d754c8e6141b759b to your computer and use it in GitHub Desktop.
One of the great things about PHP is you don't have the follow the rules when hacking stuff together. This makes map-building work easy to type up. However, since Golang there isn't much reason to use PHP anymore. Golang exceeds in every area from the stdlib to the speed and security of the application.
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 | |
// Type casting is easy on weak languages | |
$a = (object) (array) (object) (array) (object) ["foo" => "bar"]; | |
// PHP will happily iterate over an object (like Javascript) | |
foreach($a as $key => $value) { | |
print "$key = $value" . PHP_EOL; | |
} | |
$foo = "foo"; | |
$b = (array) $a; | |
// Variable variable access - even inside a string! | |
print $a->$$foo . " = {$a->$foo} = $b[$foo]" . PHP_EOL; | |
// Look at this Golang! No need for a new variable to prevent confusion! | |
$a = ['foo' => [1,2,3]]; | |
// More variable variables | |
$alias = "a"; | |
${$alias}[$foo][] = 4; | |
// Look a temp function result is functioning as a variable variable! | |
${chr(97)}[$foo][] = 5; | |
print_r($a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment