- htmlspecialchars: documentation ( source)
<?php
$File = new SplFileObject(__FILE__);
echo 'First dump: Just cast as string', "\n";
echo htmlspecialchars((string) $File), "\n";
echo 'Ok, now let\'s iterate echoing out $line var created by foreach', "\n";
foreach($File as $line) {
echo htmlspecialchars($line) , "\n";
}
echo "\n";
echo 'Ok, now let\'s echo out the object as string again', "\n";
echo htmlspecialchars((string) $File), "\n";