The situation is this: php has a variable:

$discription = 'Описание'; 

For each page its own value. How to insert a variable in the meta tag? In the design of the form:

 <meta name="discription" content= $discription > 

$ discription is displayed as a string. Tell me how to get the value of a variable in content. I would be very grateful.

  • In English, there is no word discription, there is a description. - AK

2 answers 2

If the file with the php extension:

 <meta name="discription" content="<?= $discription ?>"> 
  • Without double quotes also works: <meta name = "discription" content = <? = $ Discription?>> - Roma

It depends on how you output, if right away in a script like this:

 echo '<meta name="discription" content= ' . $discription . ' >'; 

Either way:

 echo "<meta name='discription' content= $discription >"; echo "<meta name='discription' content= {$discription} >"; 

And the best is to use шаблонизаторы . Because for example, you will have a line of the form: content = "$discription" In this case, $discription = '123"456'; then we have at the output: content = "123"456" , As you can see, it will already work incorrectly.

  • Thank you all for the advice, it all worked! - Roma