What are the advantages and disadvantages of using a text file as a storage medium for user data in PHP compared to a database like MySQL?

Using a text file as a storage medium for user data in PHP can be simpler and more lightweight compared to using a database like MySQL. However, text files lack the advanced querying capabilities and security features that databases offer. Text files are suitable for small-scale applications with limited data storage needs, while databases are more suitable for larger, more complex applications.

// Example code snippet for storing user data in a text file

$userData = "John Doe, johndoe@example.com, 30";
file_put_contents('users.txt', $userData . PHP_EOL, FILE_APPEND);