Phar::getStub

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 1.0.0)

Phar :: getStub - Phar 아카이브의 PHP 로더 또는 부트스트랩 스텁을 반환합니다.


설명

public Phar::getStub(): string

Phar 아카이브에는 다음을 통해 아카이브가 PHP에서 실행될 때 실행되는 부트스트랩 로더 또는 PHP로 작성된 스텁이 포함됩니다.

                  
<?php
include 'myphar.phar';
?>
                  
                

또는 간단한 실행으로:

php myphar.phar
                

매개변수

이 함수에는 매개변수가 없습니다.


반환 값

현재 Phar 아카이브의 부트스트랩 로더(스텁) 내용을 포함하는 문자열을 반환합니다.


오류/예외

Phar 아카이브에서 스텁을 읽을 수 없는 경우 RuntimeException이 발생합니다.


Examples

예제 #1 Phar::getStub() 예제

                  
<?php
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
echo $p->getStub();
echo "==NEXT==\n";
$p->setStub("<?php
function __autoload($class)
{
    include 'phar://' . str_replace('_', '/', $class);
}
Phar::mapPhar('myphar.phar');
include 'phar://myphar.phar/startup.php';
__HALT_COMPILER(); ?>");
echo $p->getStub();
?>
                  
                

위의 예는 다음을 출력합니다.

<?php __HALT_COMPILER(); ?>
==NEXT==
<?php
function __autoload($class)
{
    include 'phar://' . str_replace('_', '/', $class);
}
Phar::mapPhar('myphar.phar');
include 'phar://myphar.phar/startup.php';
__HALT_COMPILER(); ?>
                

기타