Trying to make meta tags with PHP

Hello! I am trying to make a PHP Application. I am sort of new to PHP (as I am more fluent in node). Anyways, I am trying to make a header with the “echo” and “include” statements.

Project URL: https://glitch.com/edit/#!/mediashare
Here is some of my code:
index.php

<html>
<!-- Load Header -->
  <?php include 'templates/header.php';?>
  <br>
  <body>
    <?php
    $number = 5;
    echo "The number of the day is $number!";
    ?>
  </body>
  <!-- Load Footer -->
  <?php include 'templates/footer.php';?>
</html>

config.php

<?php
/* Site Config */
define("SITE_NAME","Hello you! How are you today?");
define("SITE_DESCRIPTION","Hello you! How are you today?");
define("SITE_URL","Hello you! How are you today?");
define("SITE_IMG","Hello you! How are you today?");
?>

templates/header.php

<?php
require '../config.php'
  
echo '
<head>
<!-- Primary Meta Tags -->
<title>constant("SITE_NAME");</title>
<meta name="title" content="constant("SITE_NAME");">
<meta name="description" content="constant("SITE_DESCRIPTION");">

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="constant("SITE_URL");">
<meta property="og:title" content="constant("SITE_NAME");">
<meta property="og:description" content="constant("SITE_DESCRIPTION");">
<meta property="og:image" content="constant("SITE_IMG");">

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="constant("SITE_URL");">
<meta property="twitter:title" content="constant("SITE_NAME");">
<meta property="twitter:description" content="constant("SITE_DESCRIPTION");">
<meta property="twitter:image" content="constant("SITE_IMG");">
</head>
'
?>

Your problem here is that the content isn’t actually combined, it’s rather an unexpected keyword/node. The way to fix this is by adding . between the placed you want to combine.

But I rather recommend you to only open the php tag where it is necessary:

<?php require_once "../config.php"; ?>

<meta name="title" content="<?= SITE_NAME ?>" />
4 Likes