/    Sign up×
Community /Pin to ProfileBookmark

file_put_contents

I am sure I am missing something obvious. I am trying this:

file_put_contents($file,$data,’FILE_APPEND LOCK_EX’);

and have tried everything I can think of for the format of the flags. I have tried the binary OR as the manual says, nothing seems to work. I can’t get the format when using more than one flag. One flag, it works, more than one, no.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@mrshellyDec 15.2007 — try:

FILE_APPEND|LOCK_EX
Copy linkTweet thisAlerts:
@Beach_BumauthorDec 15.2007 — I tried that before, but here it is again:

<?php

$file = "test.dat";

$data = "hello";

file_put_contents($file,$data,"FILE_APPEND|LOCK_EX");

?>

Here is the error:

Warning: file_put_contents() expects parameter 3 to be long, string given in C:websiteslocalphp5_test.php on line 4

I just don't get what it wants me to do.
Copy linkTweet thisAlerts:
@ZnupiDec 15.2007 — Don't use strings, they are completely different from defined variables. Try this:
[code=php]
<?php
$file = "test.dat";
$data = "hello";
file_put_contents($file, $data, FILE_APPEND|LOCK_EX);
?>
[/code]

Note that I removed the quotes around the flags. I hope that's everything.
Copy linkTweet thisAlerts:
@Beach_BumauthorDec 16.2007 — That was my problem. Thank you.
×

Success!

Help @Beach_Bum 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...