Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7867437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:43:03+00:00 2026-06-03T00:43:03+00:00

I have a file named ‘views.txt’ which contains ‘0’. When the user loads the

  • 0

I have a file named ‘views.txt’ which contains ‘0’.
When the user loads the page, I want the script to re-write the text document to one higher from the last.

Example;

<?php
$a = file_get_contents("views.txt")
$views = $a + 1;
file_put_contents("views.txt",$views);
echo $views;
?>

It won’t display anything.

I’m unable to use MySQL, so I’m using text files. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:43:04+00:00Added an answer on June 3, 2026 at 12:43 am

    I would guess that the path to views.txt is not relative to the working directory of the file. For safety reasons, you should probably specify the full path to the file; i.e., /path/to/views.txt).

    You can also use getcwd to display the current working directory, so the location of “views.txt” will likely be getcwd() . "/views.txt".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C++, Ubunt 12.04, I have a file named config.txt which contains user name
i have a file named hello.txt which has the content Hello,there!. I want to
I have a file named file.txt which is update by adding lines to it.
I have a file named gcc.exe and I have a php page... I want
So i have a file named instance.php that contains my class listing.page 2 is
I have a file named common.cs which contains commonly used functions like this public
I have a file named a.txt which looks like this: I'm the first line
I am new to unix commands. I have a file named server.txt, which has
I have a file(both .dat and .txt format) which contains numbers(integers) in rows and
Suppose I have a file named abhishek.txt and that contains the following line I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.