Reading TEXT data from URL

Posted on 2006-11-19
Last Modified: 2008-03-06

I want to store my data in a text file and put it in an URL, something like this:

In the data.txt I will put something like this:



How can I read that content of data.txt from a PHP page?

For example, I have this PHP page:

This display.php will "generate" a web page and I need to get the content of that data.txt as part of the display.php content.

Anyone can help?

And what would be the best data structure? XML? I dont know how to read it btw :(


PS: I dont want to use database (MySQL, etc.).
Question by:klompen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 19

Accepted Solution

VoteyDisciple earned 230 total points
ID: 17974776
You can open files from URLs the same way you can open files on the server itself:

$contents = file('');

XML is probably better than a flat text format.  Here's PHP's extension for parsing XML:

There are a number of other parsers out there that you can use on their own.

Author Comment

ID: 17974991
that's what I want ! Thanks :)

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple function not working 7 43
Wordpress Query 5 43
PHP mail() function not working... 8 32
How to use 2 ON statements in inner join 3 22
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question