Created
March 27, 2017 04:40
-
-
Save anonymous/a1d1b5d5fed9148ac17de9df5a5c6937 to your computer and use it in GitHub Desktop.
魔术函数没有起作用
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 | |
// it not ok | |
class testClassb | |
{ | |
private $string = ""; | |
/** | |
* testClass constructor. | |
*/ | |
public function __construct($string) | |
{ | |
$this->string = $string; | |
} | |
//call this? | |
public function __toString() | |
{ | |
return $this->string; | |
} | |
// or call this ? | |
public function __invoke() { | |
return $this->__toString(); | |
} | |
} | |
function abc(int $arg) | |
{ | |
echo $arg; | |
} | |
abc(new testClassb('string')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment