What are the advantages and disadvantages of using text files versus PHP files for storing and updating variable values?

When deciding between using text files or PHP files for storing and updating variable values, it's important to consider the ease of access and manipulation. Text files are simpler to work with and can be easily edited manually, but PHP files offer the advantage of being able to execute code and perform more complex operations. However, PHP files may introduce security risks if not properly sanitized.

// Storing and updating variable values in a text file
$variableValue = "example";
$file = fopen("data.txt", "w");
fwrite($file, $variableValue);
fclose($file);

// Storing and updating variable values in a PHP file
$variableValue = "example";
$file = fopen("data.php", "w");
fwrite($file, "<?php \$variableValue = '$variableValue'; ?>");
fclose($file);