Is there any way that I can add the content of multiple files then put the combined values into one file?
I am currently trying this:
$start_tr = include 'include_all_items/item_input_start_tr.php' ; $img_start = include 'include_all_items/item_input_img_start.php' ; $img_link = include 'include_all_items/item_input_img_link.php' ; $img_end = include 'include_all_items/item_input_img_end.php' ; $newcontent = "$start_tr $link $img_start $_POST[img_link] $img_end "; $content = $newcontent.file_get_contents('../../include/item.computer.php'); file_put_contents('../../include/item.computer.php', $content);
Advertisement
Answer
include
is for code, not for content
. In your case you have to use file_get_contents
so you can save the returned value. include
will not give you that value.
Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1.
$start_tr = file_get_contents('include_all_items/item_input_start_tr.php'); $img_start = file_get_contents('include_all_items/item_input_img_start.php'); $img_link = file_get_contents('include_all_items/item_input_img_link.php'); $img_end = file_get_contents('include_all_items/item_input_img_end.php');
Now you can use your variable like you did.
$newcontent = "$start_tr $link $img_start $_POST[img_link] $img_end ";