Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Phar::buildFromDirectory(), directory exists --EXTENSIONS-- phar --INI-- phar.req..

Decoded Output download

--TEST--
Phar::buildFromDirectory(), directory exists
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
phar.readonly=0
open_basedir=
--FILE--
<?php

mkdir(__DIR__.'/testdir4');
foreach(range(1, 4) as $i) {
    file_put_contents(__DIR__."/testdir4/file$i.txt", "some content for file $i");
}

try {
    $phar = new Phar(__DIR__ . '/buildfromdirectory4.phar');
    $a = $phar->buildFromDirectory(__DIR__ . '/testdir4');
    asort($a);
    var_dump($a);
} catch (Exception $e) {
    var_dump(get_class($e));
    echo $e->getMessage() . "
";
}

var_dump(file_exists(__DIR__ . '/buildfromdirectory4.phar'));

?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromdirectory4.phar');
foreach(range(1, 4) as $i) {
    unlink(__DIR__ . "/testdir4/file$i.txt");
}
rmdir(__DIR__ . '/testdir4');
?>
--EXPECTF--
array(4) {
  ["file1.txt"]=>
  string(%d) "%stestdir4%cfile1.txt"
  ["file2.txt"]=>
  string(%d) "%stestdir4%cfile2.txt"
  ["file3.txt"]=>
  string(%d) "%stestdir4%cfile3.txt"
  ["file4.txt"]=>
  string(%d) "%stestdir4%cfile4.txt"
}
bool(true)

Did this file decode correctly?

Original Code

--TEST--
Phar::buildFromDirectory(), directory exists
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
phar.readonly=0
open_basedir=
--FILE--
<?php

mkdir(__DIR__.'/testdir4');
foreach(range(1, 4) as $i) {
    file_put_contents(__DIR__."/testdir4/file$i.txt", "some content for file $i");
}

try {
    $phar = new Phar(__DIR__ . '/buildfromdirectory4.phar');
    $a = $phar->buildFromDirectory(__DIR__ . '/testdir4');
    asort($a);
    var_dump($a);
} catch (Exception $e) {
    var_dump(get_class($e));
    echo $e->getMessage() . "\n";
}

var_dump(file_exists(__DIR__ . '/buildfromdirectory4.phar'));

?>
--CLEAN--
<?php
unlink(__DIR__ . '/buildfromdirectory4.phar');
foreach(range(1, 4) as $i) {
    unlink(__DIR__ . "/testdir4/file$i.txt");
}
rmdir(__DIR__ . '/testdir4');
?>
--EXPECTF--
array(4) {
  ["file1.txt"]=>
  string(%d) "%stestdir4%cfile1.txt"
  ["file2.txt"]=>
  string(%d) "%stestdir4%cfile2.txt"
  ["file3.txt"]=>
  string(%d) "%stestdir4%cfile3.txt"
  ["file4.txt"]=>
  string(%d) "%stestdir4%cfile4.txt"
}
bool(true)

Function Calls

None

Variables

None

Stats

MD5 02e0e27e887b37ecbb79b349d3bb2f49
Eval Count 0
Decode Time 104 ms