<分区>
我在 index.php 文件中有一个变量 $var,其中有一些值,我想在通过链接导航到 sample.php 后访问 sample.php 中的这个变量。我怎样才能用 js 做到这一点。
$var
<a href="sample.php" class="title">link</a>
标签 javascript php jquery html
<分区>
我在 index.php 文件中有一个变量 $var,其中有一些值,我想在通过链接导航到 sample.php 后访问 sample.php 中的这个变量。我怎样才能用 js 做到这一点。
$var
<a href="sample.php" class="title">link</a>
最佳答案
试试这个:
索引.php
<?php $var= "Great";
?>
<a href="sample.php?data=<?php echo $var;?>" class="title">link</a>
在 sample.php 中
<?php
if (isset($_GET["data"])){
echo $_GET['data'];
}
?>
关于javascript - 将数据从一个 html 传递到另一个 html 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27729046/