file_get_contens doesn`t work

Thread Solved

Join Date: May 2005
Posts: 5
Reputation: bin_asc is an unknown quantity at this point 
Solved Threads: 0
bin_asc bin_asc is offline Offline
Newbie Poster

file_get_contens doesn`t work

 
0
  #1
Sep 7th, 2008
I`m trying to load the contents of a php file, change some variables through a replace, and save it again, but upon loading, the file_get_contents doesn`t parse the start of the file for some reason. I tried this on my server and on the local server.

Example :

filesample.php :

  1. <?php
  2. $var1 = array('this' => 'that');
  3. ?>

read_file.php

  1. <?php
  2. $fp = file_get_contents('filesample.php');
  3. echo '<pre>'.$fp.'</pre>';
  4. ?>


Output :

  1. 'that');
  2. ?>

Waiting for your thoughts and experiences.
Last edited by bin_asc; Sep 7th, 2008 at 9:06 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: file_get_contens doesn`t work

 
0
  #2
Sep 7th, 2008
did you view the source. sometimes pre tags don't work for me and i know that browsers like to hide php code.
Last edited by kkeith29; Sep 7th, 2008 at 10:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: file_get_contens doesn`t work

 
0
  #3
Sep 8th, 2008
Originally Posted by kkeith29 View Post
did you view the source. sometimes pre tags don't work for me and i know that browsers like to hide php code.
I would say that kkeith has got the answer here...look at what the browser is seeing

<?php
$var1 = array('this' =>
'that');
?>

<...>

Looks like a tag to a browser ... even though it doesn't know what tag it is, so doesn't parse it, it still doesn't show it either.

  1. <?php
  2. $fp = file_get_contents('filesample.php');
  3. echo '<pre>'.htmlspecialchars($fp).'</pre>';
  4. ?>

Cheers
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 5
Reputation: bin_asc is an unknown quantity at this point 
Solved Threads: 0
bin_asc bin_asc is offline Offline
Newbie Poster

Re: file_get_contens doesn`t work

 
0
  #4
Sep 8th, 2008
Works. Thanks alot !
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC