1

I want to view each user's username inside the twitter card when they share their username or a message that they've received in my website. but the error I'm getting is that twitter meta tag is not reading the variable contents instead it is treating it as a string.

Here are my meta tags on my website:

  <meta property="twitter:card" content="summary">
  <meta name="twitter:app:name:googleplay" content="">
  <meta name="twitter:app:id:googleplay" content="">
  <meta property="twitter:site" content="">
  <meta name="twitter:title" content="<?php echo '$username'; ?>">
  <meta name="twitter:text:title" content="<?php echo '$username'; ?>">

If you can guide me on what I am doing wrong and how to do what I would like to do.

1 Answers1

2

Your PHP code needs to be either without the quotes:

<?php echo $username; ?> 

Or

<?php echo "{$username}"; ?>

See https://www.php.net/manual/en/language.types.string.php

Terence Eden
  • 14,034
  • 3
  • 48
  • 89