What are common methods for displaying the content of a text file in a text field when a button is pressed in PHP?

To display the content of a text file in a text field when a button is pressed in PHP, you can use the file_get_contents() function to read the contents of the file and then echo it into the text field.

<?php
if(isset($_POST['display_button'])){
    $file_content = file_get_contents("file.txt");
    echo '<input type="text" value="' . $file_content . '">';
}
?>
<form method="post">
    <input type="submit" name="display_button" value="Display File Content">
</form>