/    Sign up×
Community /Pin to ProfileBookmark

can we do the same as file_get_contents(), without using it?

hi what could i use to get a files contents without using file_get_contents as the php i have installed is doesnt support this and i need to get file contents,

the file is called end.txt, i cant use include as this writes it, require doesnt work, neithher does fopen

$msg1 = fopen(‘beginning.txt’);
$msg2 = fopen(‘end.txt’);
$msg3 = stripslashes($content);
$final = ” “.$msg1.” “.$msg3.” “.$msg2;

what am i missing, appreciate any help, Thanks, Rich

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@ConorApr 08.2004 — maybe just plain file()
Copy linkTweet thisAlerts:
@SamApr 08.2004 — fopen might work, but you're not using it properly

the above block would be written
[code=php]
$handle=fopen('beginning.txt',"r");
$msg1 = fread($handle, filesize('beginning.txt'));
fclose($handle);
$handle=fopen('end.txt',"r");
$msg2 = fread($handle, filesize('end.txt'));
fclose($handle);
$msg3 = stripslashes($content);
$final = " ".$msg1." ".$msg3." ".$msg2;
[/code]
Copy linkTweet thisAlerts:
@96turnerriauthorApr 08.2004 — $handle=fopen('beginning.txt',"r");

$msg1 = fread($handle, filesize('beginning.txt'));

fclose($handle);

$handle=fopen('end.txt',"r");

$msg2 = fread($handle, filesize('end.txt'));

fclose($handle);

$msg3 = stripslashes($content);

$final = " ".$msg1." ".$msg3." ".$msg2;

that works thanks, it get the file content which is htmlcode but instead of formatting it as htmljust writes it on the page, the " ". at the beginning of $final wouldnt cause that would it? maybe its something to do with the fread(), file_get_contents() would be a better solution so im trying to get the php upgraded to 4.3.0+,

Thanks

R
Copy linkTweet thisAlerts:
@SamApr 08.2004 — perhaps htmlspecialchars will do the trick?
Copy linkTweet thisAlerts:
@96turnerriauthorApr 08.2004 — htmlspecchars? thats not in the manual :/
Copy linkTweet thisAlerts:
@shimonApr 08.2004 — If u don't have file_get_contents, there's always the old fashioned way:

[code=php]$msg1 = join("", file("beginning.txt"));[/code]

which doesnt have the overheard of creating file pointers, at least
Copy linkTweet thisAlerts:
@SamApr 08.2004 — [i]Originally posted by 96turnerri [/i]

[B]htmlspecchars? thats not in the manual :/ [/B][/QUOTE]

http://www.php.net/manual/en/function.htmlspecialchars.php
Copy linkTweet thisAlerts:
@96turnerriauthorApr 08.2004 — thanks for the help guys, i will remember them for future reference, i am getting the php upgraded next week so im gonna use file_get_contents()

Thanks Again

Rich
×

Success!

Help @96turnerri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...