Created
May 10, 2013 18:47
-
-
Save Danack/5556517 to your computer and use it in GitHub Desktop.
Co-routines can be done as objects instead.
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 | |
function loggerCoroutine(){ | |
// set something up | |
$fileHandle = fopen($fileName, 'a'); | |
while($continue == true){ | |
//Do something | |
fwrite($fileHandle, yield . "\n"); | |
} | |
//close everything down | |
fclose($fileHandle); | |
} | |
class Logger{ | |
private $fileHandle; | |
function __construct(){ | |
// set something up | |
$this->fileHandle = fopen($fileName, 'a'); | |
} | |
function write($line){ | |
//Do something | |
fwrite($this->fileHandle, yield . "\n"); | |
} | |
function close(){ | |
//close everything down | |
fclose($this->fileHandle); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment