EDIT: thanks for clearing up my confusion regardign PHP and Javascript. Got to use AJAX.
I'm just messing around trying to do a basic write to file using PHP/Javascript
I have a script like
<head>
<?php
function writeToFile($file, $data) {
file_put_contents($file, $data);
}
?>
<script>
function funct() {
<?php writeToFile('text.txt', 'hello'); ?>
}
window.onload = funct;
</script>
</head>
Unfortunately, text.txt
is empty. What am I missing?