本文整理匯總了PHP中Tidy::parseFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tidy::parseFile方法的具體用法?PHP Tidy::parseFile怎麽用?PHP Tidy::parseFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tidy
的用法示例。
在下文中一共展示了Tidy::parseFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDocumentValidHtml
/**
* @param \CliTester $I
* @param \Codeception\Scenario $scenario
*/
public function testDocumentValidHtml(\CliTester $I, \Codeception\Scenario $scenario)
{
$I->wantTo('verify that the default template produces valid HTML');
if (!class_exists('Tidy')) {
$scenario->skip('Tidy is not available. See http://php.net/manual/en/tidy.installation.php');
}
$template = dirname(dirname(__DIR__)) . '/src/Task/CodeSniffer/codestyle.html';
$outfile = dirname(__DIR__) . '/_output/codestyle.html';
if (file_exists($outfile)) {
unlink($outfile);
}
$I->dontSeeFileFound($outfile);
$I->runShellCommand('vendor/bin/robo document:codestyle --outfile ' . $outfile . ' --template ' . $template);
$I->seeFileFound($outfile);
$tidy = new \Tidy();
$tidy->parseFile($outfile);
$I->assertEquals(0, $tidy->getStatus());
unlink($outfile);
}
示例2: parseArguments
error_reporting(E_ALL);
if (!version_compare(phpversion(), "5.0", ">=")) {
echo "Error: tidy.php requires PHP 5 or newer.\n";
exit(1);
}
$tidy = new Tidy();
$tmpfile = '';
// merge default options with command line arguments
$config = parseArguments($default_options);
// check if input file exists
if (!file_exists($tmpfile)) {
echo "Error: tidy.php cannot find tmpfile at: {$tmpfile} \n";
exit(1);
}
// let tidy do the work
$tidy->parseFile($tmpfile, $config, 'utf8');
// other things you can do with php's Tidy():
// $tidy->parseString($html, $options);
// $tidy->cleanRepair();
// echo $tidy;
// write buffer back to tmpfile
if (!file_put_contents($tmpfile, (string) $tidy)) {
echo "Error: The file '" . $tmpfile . "' could not be written.\n";
exit(1);
}
/**
* parseArguments: parse command line arguments and modify $defaults array
* @param array $defaults tidy config array to be modified
* @return array modified config array
*/
function parseArguments($defaults)