I have a website running PHP 7.4 on ubuntu 20.04 with a form with a textarea element. Here is how it is setup.
<form id="user-input">
<textarea name="usertags">
</textarea>
</form>
When the user clicks the submit button, I am doing a POST fetch request using FormData and JSON.stringify in Javascript
formData = new FormData(document.getElementById("user-input"));
async function postUserAction(formData) {
const response = await fetch('https://example.com/action.php', {
method: 'POST',
body: JSON.stringify(Object.fromEntries(formData))
});
return await response.json();
On the PHP backend
$json = file_get_contents('php://input');
$data = json_decode($json);
$tags= explode(PHP_EOL, $data->usertags);
Now, my question is if the PHP_EOL is cross platform safe regardless of what browser/system/device the user is using? I am storing the tags in a database so I need to be able to get consistent results.