i'm creating small classroom-app website, students logging in random generated code teacher give them. need every student have unique code i'm using following script
$count = file_get_contents($classcode . "/count.txt"); $count = $count + 1; file_put_contents($classcode . "/count.txt", $count);
now question is, clients able receive same value $count
if load page simultaneously? , maybe has better way such thing?
to answer question, yes, file can overwritten unless lock it
file_put_contents($file, $person, file_append | lock_ex);
documentation: file_put_contents
more info - file_get_contents not respect file locking
Comments
Post a Comment