如何使用包含的php文件中的php变量 [英] How to use php variables from an included php file

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

问题描述

我在一个php文件中设置了这些变量,当我将php文件包含在另一个php文件中时,如何使用包含的php文件中的那些变量?

I have these variables that are set in one php file, and when i include that php file in another php file, how do i use those variables from the included php file?

推荐答案

他们应该翻身:

File1.php

File1.php

<?php
$var1 = "TEST";
?>

File2.php

File2.php

<?php
include("File1.php");
echo $var1; //Outputs TEST
?>

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

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