如何使file_get_contents将转义序列识别为特殊字符?

I need to get content from a file so that the escape sequences (like ) got recognized as special characters.

Consider the code:

<?php
$f = file_get_contents("test.txt");
echo "$f";
?>

while test.txt contains only:

Test
Only

It echoes:

Test
Only

while I'd like to have:

Test
Only

Is there a way to accomplish it with file_get_content or should I use something else (like output buffering)?

try using printf which the function outputs a formatted string.

<?php
$f = file_get_contents("test.txt");
printf ($f);
?>