Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can also do like this. Inserting your <strong>PHP</strong> inside the <strong><code>&lt;meta&gt;</code></strong> tags too.</p> <pre><code>&lt;?php $metaKeywords="books,cars,bikes"; ?&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;/meta&gt; &lt;title&gt;SomePage&lt;/title&gt; &lt;meta name="description" content="&lt;?php echo 'somedescription' ?&gt;"&gt;&lt;/meta&gt; &lt;meta name="keywords" content="&lt;?php echo $metaKeywords ?&gt;"&gt;&lt;/meta&gt; &lt;/head&gt; </code></pre> <p>EDIT:</p> <p><strong>Solution 1:</strong> Make use of <strong><code>HEREDOC</code></strong>, Its pretty easier.</p> <pre><code>&lt;?php $metaTag=&lt;&lt;&lt;EOD &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;/meta&gt; &lt;title&gt;SomePage&lt;/title&gt; &lt;meta name="description" content="my description here"&gt;&lt;/meta&gt; &lt;meta name="keywords" content="cars,bikes,books"&gt;&lt;/meta&gt; &lt;/head&gt; EOD; echo $metaTag; ?&gt; </code></pre> <p><strong>Solution 2:</strong> You can also embed variables inside the <strong><code>HEREDOC</code></strong>. </p> <pre><code>&lt;?php $metaDesc="this is new"; $metaKeywords="cars,bikes,thrills"; $metaTag=&lt;&lt;&lt;EOD &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;/meta&gt; &lt;title&gt;SomePage&lt;/title&gt; &lt;meta name="description" content=$metaDesc&gt;&lt;/meta&gt; &lt;meta name="keywords" content=$metaKeywords&gt;&lt;/meta&gt; &lt;/head&gt; EOD; echo $metaTag;//Don't forget to echo ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload