php in html file code example

Example 1: load php in html

//Safe as:
index.html
number.php

//HTML:
<html>
   <head>
      <title>Home</title>
   </head>
   <body>
      <h1>Phone Number</h1>
      <?php include('number.php') ?>
   </body>
</html>

//PHP:
<?php
   echo 4895553268;
?>

Example 2: insert an html page into php

<?php
// do php stuff

include('fileOne.html');
include('fileTwo.html');

?>

Example 3: php in html

Basic PHP Syntax
A PHP script can be placed anywhere in the document.

A PHP script starts with <?php and ends with ?>:

<?php
// PHP code goes here
?>
The default file extension for PHP files is ".php".

A PHP file normally contains HTML tags, and some PHP scripting code.
  
Example
<!DOCTYPE html>
<html>
<body>

<h1>Php in html</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

Example 4: php hello world

echo "Hello, World!";

Example 5: inline php in html

<body>
Hello, today is <?php echo date('l, F jS, Y'); ?>.
</body>

Tags:

Php Example