Theoreticaly, i thought this could work.....

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
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

Theoreticaly, i thought this could work.....

Post by Monotoko »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


this is index.php, which should open main.txt and display it in a textbox, only thing is, its not displayin it in the textbox

Code: Select all

<html>
<body>
<textarea rows="10" cols="30">
<?
$ourFileName = "main.txt";
$fh = fopen($ourFileName, 'r') or die("Can't open file");
echo "$fh"
fclose($fh);
?>
</textarea>
</body>
</html>
main.txt has "hello" inside it, but instead its giving me "Resource id #3"

can anyone help me make it so it displays the contents of main.txt in the textarea?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Code: Select all

<html> 
<body> 
<textarea rows="10" cols="30"> 
<? 
$ourFileName = "main.txt"; 
$fh = fopen($ourFileName, 'r') or die("Can't open file"); 
echo fread($fh, filesize());
fclose($fh); 
?> 
</textarea> 
</body> 
</html>
Notice the additional fread
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

A simple

Code: Select all

echo file_get_contents($filename);
would work.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

htmlspecialchars() will also be needed.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

and even simpler

Code: Select all

readfile($filename);
would work as well
Post Reply