라이브러리

[PHP] ReflectionFiber::getCallable - Fiber를 생성하는 데 사용되는 호출 가능 항목을 가져옵니다.




ReflectionFiber::getCallable


PHP 8.1 버전부터 ReflectionFiber::getCallable 메소드가 추가되었습니다. 이 메소드는 현재 실행 중인 Fiber의 callable 정보를 반환합니다.

# 사용법


ReflectionFiber::getCallable 메소드는 ReflectionFunction 또는 ReflectionMethod 객체를 반환합니다. 이 객체는 현재 실행 중인 Fiber의 callable 정보를 포함합니다.

# 예제


#hostingforum.kr
php

<?php



// Fiber 함수를 정의합니다.

function myFiber() {

    echo "Fiber가 실행 중입니다.
";

}



// ReflectionFiber::getCallable 메소드를 사용하여 callable 정보를 얻습니다.

$reflection = ReflectionFiber::getCallable();



// ReflectionFunction 또는 ReflectionMethod 객체를 사용하여 callable 정보를 확인합니다.

echo "Callable 이름: " . $reflection->getName() . "
";

echo "Callable 유형: " . gettype($reflection) . "
";



// Fiber를 실행합니다.

ReflectionFiber::release();



// Fiber를 다시 실행합니다.

ReflectionFiber::suspend();

myFiber();

ReflectionFiber::resume();



?>



# 결과


#hostingforum.kr


Callable 이름: myFiber

Callable 유형: ReflectionFunction

Fiber가 실행 중입니다.



# 설명


위 예제에서, `myFiber` 함수를 정의하고 `ReflectionFiber::getCallable` 메소드를 사용하여 callable 정보를 얻습니다. `ReflectionFunction` 객체를 사용하여 callable 이름과 유형을 확인합니다. 그리고 Fiber를 실행하고 다시 실행합니다.

# 참고


* ReflectionFiber::getCallable 메소드는 현재 실행 중인 Fiber의 callable 정보를 반환합니다.
* ReflectionFunction 또는 ReflectionMethod 객체를 반환합니다.
* callable 이름과 유형을 확인할 수 있습니다.
* Fiber를 실행하고 다시 실행할 수 있습니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 10,077건 / 284 페이지

검색

게시물 검색