Skip to content

Instantly share code, notes, and snippets.

Created March 27, 2017 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a1d1b5d5fed9148ac17de9df5a5c6937 to your computer and use it in GitHub Desktop.
Save anonymous/a1d1b5d5fed9148ac17de9df5a5c6937 to your computer and use it in GitHub Desktop.
魔术函数没有起作用
<?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