如何从多个文件访问内容

编程入门 行业动态 更新时间:2024-10-10 21:34:02
本文介绍了如何从多个文件访问内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有什么方法可以添加多个文件的内容,然后将合并的值放入一个文件中?

Is there any way that I can add the content of multiple files then put the combined values into one file?

我目前正在尝试:

$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/itemputer.php'); file_put_contents('../../include/itemputer.php', $content);

推荐答案

include 用于代码,而不用于 content .您必须使用 file_get_contents 来保存返回的值. include 不会赋予您该值.

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.

include()

处理返回值:include失败时返回FALSE并发出警告.成功包含,除非被包含的文件覆盖,否则返回1.

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 ";

更多推荐

如何从多个文件访问内容

本文发布于:2023-11-28 14:30:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   文件   内容

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!