如何使用包含的 php 文件中的 php 变量

2022-01-25 00:00:00 variables scope include 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?

解决方案

They should just roll over:

File1.php

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

File2.php

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

相关文章