How do you link HTML file to your php one?

How do you link a PHP file to your HTML one? what tag? like for CSS and javascript you use these.

<head>
 <!-- import the webpage's stylesheet -->
    <link rel="stylesheet" href="/style.css" />

    <!-- import the webpage's javascript file -->
    <script rel="preload" src="/script.js" defer></script>
</head>

like if you want to link help.PHP

do you do this

<link rel="PHP" src="/help.PHP" />

No. You would usually have a mix of HTML and PHP in your file. Something like:

html code
<?php
php code
?>
more html code
<?php
more php code
?>
yet more html code

Or maybe an include is more what you wanted:

<?php
include ("help.php");
?>
2 Likes

I mean what HTML tag do you use

You don’t. Php is a server-side scripting language. It is executed (parsed, tokenized, and interpreted) on the server when the page is requested. The purpose of php is to build and output (dynamic) web pages and perform actions on the server.

The css and javascrpt link and script tags are html markup. The target urls in them are requested by the browser, where they are then parsed and rendered/executed in the browser.

You can use a url to a php page in the html markup, but when the browser requests that url, the php code is executed on the server and only the output from that php code is sent to the browser.

If this and the other replies do not address your question, you will need to be more specific about what it is you are trying to accomplish or what problem you are trying to solve.

1 Like

That probably explains things well enough. I will add to that in case it helps.

For a HTML file the server reads the file and sends it to the client as-is. The browser gets the file the same or nearly the same as it exists in the server.

Many languages, including PHP, C# and VB.Net, are executed server-side, as mabismad says. For them the server reads the file but during the reading it compiles and executes the relevant code when it exists in the file.

Whether the file is a HTML file or a PHP file or a file with C# or VB.Net or any server-side language, the CSS and JavaScript files are sent to the browser as-is for execution in the browser. JavaScript can also be used server-side but I assume that is not relevant here.

I’ll get this is before @benanamen :grin:
What problem are you trying to solve here?

2 Likes

Please note that the web page file must have a “.php” extension and not “.html”.

There are convoluted ways to load PHP files into a HTML file with a “.html” extension but I do not think it is relevant to this topic.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.