Created
December 2, 2015 14:53
-
-
Save wbond/82e6d8cf56ccfaab8894 to your computer and use it in GitHub Desktop.
How PHP closures have to be created and how I wish they could also be created.
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 | |
$conn = fsockopen('localhost', 8080); | |
$send = function($data) use ($conn) { | |
fwrite($conn, $data); | |
} | |
$send('Hello'); | |
$send('World'); | |
$send('\n'); |
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 | |
$conn = fsockopen('localhost', 8080); | |
function send($data) use ($conn) { | |
fwrite($conn, $data); | |
} | |
send('Hello'); | |
send('World'); | |
send('\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment