Phar::setDefaultStub

(Unknown)

Phar::setDefaultStubUsed to set the PHP loader or bootstrap stub of a Phar archive to the default loader

說明

public bool Phar::setDefaultStub ([ string $index [, string $webindex ]] )

Note:

此方法需要 將 php.ini 中的 phar.readonly 設為 0 以適合 Phar 對象。否則, 將拋出PharException.

This method is a convenience method that combines the functionality of Phar::createDefaultStub() and Phar::setStub().

參數

index

Relative path within the phar archive to run if accessed on the command-line

webindex

Relative path within the phar archive to run if accessed through a web browser

回傳值

如果成功則回傳 TRUE,失敗則回傳 FALSE

錯誤/例外

UnexpectedValueException is thrown if phar.readonly is enabled in php.ini. PharException is thrown if any problems are encountered flushing changes to disk.

範例

Example #1 A Phar::setDefaultStub() example

<?php
try {
    
$phar = new Phar('myphar.phar');
    
$phar->setDefaultStub('cli.php''web/index.php');
    
// this is the same as:
    // $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php'));
} catch (Exception $e) {
    
// handle errors
}
?>

參見

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top