如何从 html 调用 php 函数(基于本地)

How to call a php function from html (local based)

我是 PHP 和 HTML 的新手,所以我请求你们帮助我:我正在尝试从外部调用函数。php文件从 .html 文件回显 header 标题。如果这甚至可能,我怎么称呼它?非常感谢。

你可以这样做:

<html>
    <head>
        <title>PHP Echo Demo</title>
    </head>
    <body>
        <h1><?php echo 'Hi this is a tilte'; ?></h1>
        <p><?php echo 'Hi this is a body'; ?></p>
    </body>
</html>

或者你可以这样做:

<?php 
    function title() {
        return echo 'Hi I am a title';
    } 
?>
<html>
    <head>
        <title>PHP Function Echo Demo</title>
    </head>
    <body>
        <h1><?php return title(); ?></h1>
    </body>
</html>