| | |
file_get_contens doesn`t work
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2005
Posts: 5
Reputation:
Solved Threads: 0
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 :
read_file.php
Output :
Waiting for your thoughts and experiences.
Example :
filesample.php :
php Syntax (Toggle Plain Text)
<?php $var1 = array('this' => 'that'); ?>
read_file.php
php Syntax (Toggle Plain Text)
<?php $fp = file_get_contents('filesample.php'); echo '<pre>'.$fp.'</pre>'; ?>
Output :
PHP Syntax (Toggle Plain Text)
'that'); ?>
Waiting for your thoughts and experiences.
Last edited by bin_asc; Sep 7th, 2008 at 9:06 pm.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
•
•
•
•
did you view the source. sometimes pre tags don't work for me and i know that browsers like to hide php code.
<?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.
php Syntax (Toggle Plain Text)
<?php $fp = file_get_contents('filesample.php'); echo '<pre>'.htmlspecialchars($fp).'</pre>'; ?>
Cheers
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Dynamic HTML link with Nested PHP
- Next Thread: calling function name? i need help
| Thread Tools | Search this Thread |
ajax apache api array basics beginner binary bounce broken cakephp checkbox class cms code codingproblem combobox cron curl database date display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla js limit link login mail menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote return script search server sessions smash sms soap source space sql syntax system table tutorial up-to-date update upload url validation validator variable video web webapplications websitecontactform xml youtube






