【问题标题】:How to Pass data from PHP to PHP file [duplicate]如何将数据从 PHP 传递到 PHP 文件 [重复]
【发布时间】:2020-05-30 12:49:42
【问题描述】:

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

我用

include('index.php');

用于包含索引数据。有没有办法将数据传递给 index.php 文件?

【问题讨论】:

  • include之前定义的所有全局变量在包含的PHP代码中也可用。
  • 是index.php在1.php里面吗?
  • 您是在尝试将数据从 1.php 传递到 index.php 还是相反?
  • 如果您想将数据从一个页面发送到另一个页面,我建议您查看 PHP 中的 POST 变量
  • 是的 index.php 在 1.php 文件中@EbrahimMohammed

标签: php


【解决方案1】:

如果 index.php 在 1.php 里面,你可以这样做:

1.php:

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

index.php

<?php 
echo $variable; //this will output hello.
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-02
    • 2021-05-18
    • 2016-10-14
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多