當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Phar::setInfoClass方法代碼示例

本文整理匯總了PHP中Phar::setInfoClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phar::setInfoClass方法的具體用法?PHP Phar::setInfoClass怎麽用?PHP Phar::setInfoClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phar的用法示例。


在下文中一共展示了Phar::setInfoClass方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Phar

<?php

require_once 'files/phar_oo_test.inc';
$phar = new Phar($fname);
$phar->setInfoClass('SplFileInfo');
foreach ($phar as $name => $ent) {
    var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
    var_dump($ent->getFilename());
    var_dump($ent->getSize());
    var_dump($ent->getType());
    var_dump($ent->isWritable());
    var_dump($ent->isReadable());
    var_dump($ent->isExecutable());
    var_dump($ent->isFile());
    var_dump($ent->isDir());
    var_dump($ent->isLink());
    var_dump($ent->getCTime());
    var_dump($ent->getMTime());
    var_dump($ent->getATime());
}
echo "==RECURSIVE==\n";
$phar = new Phar($fname);
foreach (new RecursiveIteratorIterator($phar) as $name => $ent) {
    var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
    var_dump(str_replace('\\', '/', $ent->getFilename()));
    var_dump($ent->getCompressedSize());
    var_dump($ent->isCRCChecked());
    var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
    var_dump($ent->getPharFlags());
}
?>
開發者ID:gleamingthecube,項目名稱:php,代碼行數:31,代碼來源:ext_phar_tests_phar_oo_002U.php

示例2: Phar

<?php

$pharconfig = 1;
require_once 'files/phar_oo_test.inc';
$phar = new Phar($fname);
$phar->setInfoClass('SplFileObject');
$f = $phar['a.csv'];
echo "===1===\n";
foreach ($f as $k => $v) {
    echo "{$k}=>{$v}\n";
}
$f->setFlags(SplFileObject::DROP_NEW_LINE);
echo "===2===\n";
foreach ($f as $k => $v) {
    echo "{$k}=>{$v}\n";
}
class MyCSVFile extends SplFileObject
{
    function current()
    {
        return parent::fgetcsv(',', '"');
    }
}
$phar->setInfoClass('MyCSVFile');
$v = $phar['a.csv'];
echo "===3===\n";
while (!$v->eof()) {
    echo $v->key() . "=>" . join('|', $v->fgetcsv()) . "\n";
}
echo "===4===\n";
$v->rewind();
開發者ID:gleamingthecube,項目名稱:php,代碼行數:31,代碼來源:ext_phar_tests_phar_oo_008.php

示例3: Phar

<?php

require_once 'files/phar_oo_test.inc';
$phar = new Phar($fname);
$phar->setInfoClass();
foreach ($phar as $name => $ent) {
    var_dump($ent->getFilename());
    if ($ent->isDir()) {
        var_dump('DIR');
    } else {
        var_dump($ent->openFile()->fgets());
        include $ent->getPathName();
    }
}
?>
===DONE===
開發者ID:gleamingthecube,項目名稱:php,代碼行數:16,代碼來源:ext_phar_tests_phar_oo_003.php

示例4: Phar

<?php

try {
    $pharconfig = 0;
    require_once 'files/phar_oo_test.inc';
    $phar = new Phar($fname);
    $phar->setInfoClass('SplFileObject');
    $phar['f.php'] = 'hi';
    var_dump(isset($phar['f.php']));
    echo $phar['f.php'];
    echo "\n";
    unset($phar['f.php']);
    var_dump(isset($phar['f.php']));
} catch (BadMethodCallException $e) {
    echo "Exception: " . $e->getMessage() . "\n";
}
?>
===DONE===
<?php 
unlink(dirname(__FILE__) . '/files/phar_oo_012b.phar.php');
__halt_compiler();
?>
開發者ID:alphaxxl,項目名稱:hhvm,代碼行數:22,代碼來源:phar_oo_012b.php

示例5: dirname

<?php

require_once 'files/phar_oo_test.inc';
class MyFile extends SplFileObject
{
    function __construct($name)
    {
        echo __METHOD__ . "(" . str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name) . ")\n";
        parent::__construct($name);
    }
}
$phar = new Phar($fname);
$phar->setInfoClass('MyFile');
$f = $phar['a.php'];
$s = $f->fstat();
var_dump($s['atime']);
var_dump($s['ctime']);
var_dump($s['mtime']);
var_dump($f->ftell());
var_dump($f->eof());
var_dump($f->fgets());
var_dump($f->eof());
var_dump($f->fseek(20));
var_dump($f->ftell());
var_dump($f->fgets());
var_dump($f->rewind());
var_dump($f->ftell());
var_dump($f->fgets());
var_dump($f->ftell());
?>
===AGAIN===
開發者ID:gleamingthecube,項目名稱:php,代碼行數:31,代碼來源:ext_phar_tests_phar_oo_007.php


注:本文中的Phar::setInfoClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。