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-- Test fprintf() function (variation - 9) --FILE-- <?php $string_variation = array..

Decoded Output download

--TEST--
Test fprintf() function (variation - 9)
--FILE--
<?php

$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" );
$strings = array( NULL, "abc", 'aaa' );

/* creating dumping file */
$data_file = __DIR__ . '/fprintf_variation_009.txt';
if (!($fp = fopen($data_file, 'wt')))
   return;

$counter = 1;
/* string type variations */
fprintf($fp, "
*** Testing fprintf() for string types ***
");
foreach( $string_variation as $string_var ) {
  fprintf( $fp, "
-- Iteration %d --
",$counter);
  foreach( $strings as $str ) {
    fprintf( $fp, "
");
    fprintf( $fp, $string_var, $str );
  }
  $counter++;
}

fclose($fp);

print_r(file_get_contents($data_file));
echo "
Done";

unlink($data_file);

?>
--EXPECT--
*** Testing fprintf() for string types ***

-- Iteration 1 --

     
  abc
  aaa
-- Iteration 2 --

     
abc  
aaa  
-- Iteration 3 --

00000
00abc
00aaa
-- Iteration 4 --

#####
##abc
##aaa
Done

Did this file decode correctly?

Original Code

--TEST--
Test fprintf() function (variation - 9)
--FILE--
<?php

$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" );
$strings = array( NULL, "abc", 'aaa' );

/* creating dumping file */
$data_file = __DIR__ . '/fprintf_variation_009.txt';
if (!($fp = fopen($data_file, 'wt')))
   return;

$counter = 1;
/* string type variations */
fprintf($fp, "\n*** Testing fprintf() for string types ***\n");
foreach( $string_variation as $string_var ) {
  fprintf( $fp, "\n-- Iteration %d --\n",$counter);
  foreach( $strings as $str ) {
    fprintf( $fp, "\n");
    fprintf( $fp, $string_var, $str );
  }
  $counter++;
}

fclose($fp);

print_r(file_get_contents($data_file));
echo "\nDone";

unlink($data_file);

?>
--EXPECT--
*** Testing fprintf() for string types ***

-- Iteration 1 --

     
  abc
  aaa
-- Iteration 2 --

     
abc  
aaa  
-- Iteration 3 --

00000
00abc
00aaa
-- Iteration 4 --

#####
##abc
##aaa
Done

Function Calls

None

Variables

$strings [{'key': 0, 'value': 0}, {'key': 1, 'value': 'abc'}, {'key': 2, 'value': 'aaa'}]
$string_variation [{'key': 0, 'value': '%5s'}, {'key': 1, 'value': '%-5s'}, {'key': 2, 'value': '%05s'}, {'key': 3, 'value': "%'#5s"}]

Stats

MD5 0e3556574be471a908658636c7e41579
Eval Count 0
Decode Time 93 ms