本文整理汇总了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());
}
?>
示例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();
示例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===
示例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();
?>
示例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===