如何将数据从PHP传递到PHP文件[重复]

问题描述 投票:-1回答:1

我有一个名为1.php的文件,而我有另一个名为index.php的文件

我使用

include('index.php');

包括索引数据。有什么方法可以将数据传递到index.php文件吗?

php
1个回答
1
投票

如果index.php位于1.php内,则可以这样做:

1.php:

<?php $variable = "hello"; 
      include('index.php');
?>

index.php

<?php 
echo $variable; //this will output hello.
?>
© www.soinside.com 2019 - 2024. All rights reserved.