LoginSignup
0
1

More than 5 years have passed since last update.

call_user_funcの小さなサンプル

Posted at

コード

<?php

function test(){
        echo "func test".PHP_EOL;
}

class TestClass{
        public function __construct(){
                echo "TEST".PHP_EOL;
        }
        public function test(){
                echo "test".PHP_EOL;
        }
}

call_user_func("test");

$testClass = new TestClass();
call_user_func(array($testClass, "test"));

call_user_func(function(){ echo "no name".PHP_EOL; });

実行

func test
TEST
test
no name
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1