Elektron Posted December 13, 2009 at 11:58 PM Report Share #300232 Posted December 13, 2009 at 11:58 PM Estou a tentar fazer um contador de visitas em php. <html> <body> <?php $_d=fopen("data.txt","r+"); while ((flock ($_d,LOCK_EX))==TRUE) { } $_var=TRUE; flock($_d,LOCK_EX,$_var); $_s=fgets($_d); $_i=(int)$_s; $_i=$_i+1; $_s=strval($_i); echo $_i; rewind($_d); fwrite($_d,$_s); flock($_d,LOCK_UN); fclose($_d); ?> </body> </html> Tentei usar flock mas mesmo assim, quando abro duas abas do browser as duas retornam o mesmo valor. Desde ja agradeço as respostas. Link to comment Share on other sites More sharing options...
softklin Posted December 14, 2009 at 09:50 AM Report Share #300255 Posted December 14, 2009 at 09:50 AM Porque escreves o $_s no ficheiro, quando deveria ser o $_i, não testei, mas pareceu-me ser disso. Nick antigo: softclean | Tens um projeto? | Wiki P@P Ajuda a comunidade! Se encontrares algo de errado, usa a opção "Denunciar" por baixo de cada post. Link to comment Share on other sites More sharing options...
Recommended Posts
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