PHP: fwrite large string

Asked by At

i'm trying to write a large string but it keeps failing. I shorten the string in half and it works fine.

How do i write the whole string into one file?

Here's what i've attempted so far...

I broke the large string into individual strings.

$cups_defaultsettings = fopen($displayname.'.ppd.O', "w+") or die("file not open");

$toshiba_universal_Default = "long ass string";
$toshiba_universal_Default2 = "more";

$toshiba_universal_default_cups = $toshiba_universal_Default."'".$toshiba_universal_Default2;

fwrite($cups_defaultsettings,$toshiba_universal_default_cups) or die("Data not write");

I get a blank page even with php errors on.

2 Answers

Barmar On

You may be running out of memory trying to concatenate the strings. Just write them separately instead of concatenating.

fwrite($cups_defaultsettings, $toshiba_universal_Default);
fwrite($cups_defaultsettings, "'");
fwrite($cups_defaultsettings, $toshiba_universal_Default2);
Kyocera Alerts On

The solution was that the long string had single quotes that were breaking the string.

Thank you.