包含文件内容php [英] include file content php

查看:148
本文介绍了包含文件内容php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将php文件中的内容包含到另一个php文件中。 (它在wordpress网站上)

包含或要求不起作用,因为它只包含文件,我需要内容本身。

file_get_contents也不起作用,因为它只是显示我的PHP代码并没有执行它。

I want to include the content from a php file into another php file. (It's in a wordpress site)
Include or require won't work because it's just including the file, I need the content itself.
file_get_contents is also not working because it just displays my php code and does not execute it.

我必须使用什么功能?

推荐答案


包含或要求不起作用,因为它只包含文件

Include or require won't work because it's just including the file

暂停。什么? 包含包含文件中的代码。我确定这就是你想要的。例如,请参阅下面的代码。 test.php 包含 vars.php ,并且能够回显来自的变量vars.php

Pause. What? Include includes the code in the file for you. I'm sure this is what you want. For instance, see the code below. test.php has vars.php included in it and its able to echo the variables from vars.php

//vars.php
----------
<?php

$color = 'green';
$fruit = 'apple';

?>
----------

//test.php
----------
<?php

echo "A $color $fruit"; // A

include 'vars.php';

echo "A $color $fruit"; // A green apple

?>

这篇关于包含文件内容php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆