简体   繁体   English

发送PHP数据到HTML页面

[英]Send php data to html page

I have two html pages that include php part and I want to send php value from first html page to second html page. 我有两个包含php部分的html页面,我想将PHP值从第一个html页面发送到第二个html页面。 Normally it's like... /page2.php?uid=$uid but my pages' extension is not .php , it is .html but its include php part. 通常,它就像... /page2.php?uid=$uid但我页面的扩展名不是.php ,它是.html但包含php部分。 So how can I do it please? 那我该怎么办呢?

Thank you all I just change all html pages to php pages. 谢谢大家,我只是将所有html页面更改为php页面。

Send your value like this: 像这样发送您的值:

file_1.php file_1.php

<a href="file_2.php?var=variable">send</a>

file_2.php file_2.php

<?php
    $variable = $_GET['var'];
?>

best way is to use rewrite in your .htaccess file : 最好的方法是在.htaccess文件中使用重写:

rewrite /(.*)-([0-9]+).html$ $1.php?uid=$2 [nc,L]

if you type in url : 如果您输入url:

/page-58.html  

then your php file must be 那么您的php文件必须是

page.php 

and you can get input value as $_GET['uid'] that was 58 in this case . 并且您可以得到输入值$_GET['uid']在这种情况下为58。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM