PHP help (again)
Go to solution
Solved by mariushm,
You can use fopen and fread and fclose or you could just use file_get_contents and file_put_contents
Something like this
<?php // __DIR__ is the folder where this script is saved $path = __DIR__ .'/forbidden/counter.txt'; $content = file_get_contents($path); if ($content===FALSE) { die("Fail: file $path not found.\n"); } $value = intval($content); $value++; $result = file_put_contents($path,$value); // output something here if you want to // header('Content-Type: application/vnd.api+json'); // echo json_encode(array('counter'=>$value, 'success'=>TRUE)); ?>
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now