reading a php file with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shylor
Forum Newbie
Posts: 13
Joined: Thu Sep 27, 2007 12:52 pm

reading a php file with php

Post by shylor »

ok, in order for me to make my update script I need a way to read php files, with php. What I mean by this is, I need to update code line by line. I can not make an update to a html file, because then its not really updating what needs to be updated.

I might have to add another variable to a config file. So I need a function that can read a php file as is. I tried another way and it could only read the html and the php would not show.

Many php sites have one config file holding all the variables. In order to update that file you would need to remove it and add a new one. Well, on a web script I am unsure what my users have entered, so I can not just enter a blank one. I need a way to read a raw php file, then be able to add a line at line 26 and then at 32 and so on.

The thing is that I might have to add a line or replace a line. Here in total is what I need my script to do, I am only asking for help how to get to this point and not someone to write it.

I am sure some of you have used easymod for phpbb sites. It is a zip file, that has a long file with a set of install rules, the site reads the rules and updates the site as needed.

Code: Select all

---------------------------------------------
# below: include('header.inc.php');
---------------------------------------------
include('config.inc.php');

---------------------------------------------
# above: $url = 'http://mysite.com';
---------------------------------------------
$site_title = 'mysite';

---------------------------------------------
# End
---------------------------------------------
See this file would give the site information how to update the page. However my big issues at the minute is I can not find a function that will read and write the the raw php file, normally they get the file after it has been turned into HTML, and by that time, my update system would be no good.

I have a good understanding of php, however have little experience in file work.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

shylor
Forum Newbie
Posts: 13
Joined: Thu Sep 27, 2007 12:52 pm

Post by shylor »

ok thanks, I was unsure if those could read the raw php file.
Post Reply