gpt4 book ai didi

php - 使用外部 php 文件中的变量在 html 中的 div 中显示文本

转载 作者:行者123 更新时间:2023-11-28 03:07:04 25 4
gpt4 key购买 nike

我想在 html 的 div 中显示文本。所以通常我可以这样做。

<div class = "profileText" style = "margin-top: 5%;">Hello</div> <br>

我想做的是使用来自另一个 php 文件的变量显示文本。就像我在名为 profileLoad.php 的 php 文件中有这些变量

<?php
$firstname = "Arnab";
$lastname = "Das";
?>

我搞不懂,我是 php/html/css 的初学者。

最佳答案

使用include/require函数在html文件的开头包含php文件。然后简单地 echo $firstname.''.$lastname;

关于php - 使用外部 php 文件中的变量在 html 中的 div 中显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32169736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com