Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3195

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Extracts all meta tag content attributes from a file and returns an array</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-headers.html">get_headers</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-build-query.html">http_build_query</a></div>
 <div class="up"><a href="ref.url.html">URL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.get-meta-tags" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_meta_tags</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">get_meta_tags</span> &mdash; <span class="dc-title">Extracts all meta tag content attributes from a file and returns an array</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.get-meta-tags-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>get_meta_tags</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_include_path</code><span class="initializer"> = false</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Opens <em><code class="parameter">filename</code></em> and parses it line by line for
   &lt;meta&gt; tags in the file. The parsing stops at
   <em>&lt;/head&gt;</em>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.get-meta-tags-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">filename</code></em></span>
     <dd>

      <p class="para">
       The path to the HTML file, as a string. This can be a local file or an
       <acronym title="Uniform Resource Locator">URL</acronym>.
      </p>
      <p class="para">
       <div class="example" id="example-4083">
        <p><strong>Example #1 What  <span class="function"><strong>get_meta_tags()</strong></span> parses</strong></p>
        <div class="example-contents">
<div class="htmlcode"><pre class="htmlcode">&lt;meta name=&quot;author&quot; content=&quot;name&quot;&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;php documentation&quot;&gt;
&lt;meta name=&quot;DESCRIPTION&quot; content=&quot;a php manual&quot;&gt;
&lt;meta name=&quot;geo.position&quot; content=&quot;49.33;-86.59&quot;&gt;
&lt;/head&gt; &lt;!-- parsing stops here --&gt;</pre>
</div>
        </div>

       </div>
       (pay attention to line endings - PHP uses a native function to
       parse the input, so a Mac file won&#039;t work on Unix).
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">use_include_path</code></em></span>
     <dd>

      <p class="para">
       Setting <em><code class="parameter">use_include_path</code></em> to <strong><code>TRUE</code></strong> will result
       in PHP trying to open the file along the standard include path as per
       the <a href="ini.core.html#ini.include-path" class="link">include_path</a> directive.
       This is used for local files, not URLs.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-meta-tags-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array with all the parsed meta tags.
  </p>
  <p class="para">
   The value of the name property becomes the key, the value of the content
   property becomes the value of the returned array, so you can easily use
   standard array functions to traverse it or access single values. 
   Special characters in the value of the name property are substituted with
   &#039;_&#039;, the rest is converted to lower case.  If two meta tags have the same
   name, only the last one is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.get-meta-tags-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.0.5</td>
       <td>
        Support for unquoted HTML attributes was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.get-meta-tags-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4084">
    <p><strong>Example #2 What  <span class="function"><strong>get_meta_tags()</strong></span> returns</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Assuming&nbsp;the&nbsp;above&nbsp;tags&nbsp;are&nbsp;at&nbsp;www.example.com<br /></span><span style="color: #0000BB">$tags&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">get_meta_tags</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.com/'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Notice&nbsp;how&nbsp;the&nbsp;keys&nbsp;are&nbsp;all&nbsp;lowercase&nbsp;now,&nbsp;and<br />//&nbsp;how&nbsp;.&nbsp;was&nbsp;replaced&nbsp;by&nbsp;_&nbsp;in&nbsp;the&nbsp;key.<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$tags</span><span style="color: #007700">[</span><span style="color: #DD0000">'author'</span><span style="color: #007700">];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;name<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$tags</span><span style="color: #007700">[</span><span style="color: #DD0000">'keywords'</span><span style="color: #007700">];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;php&nbsp;documentation<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$tags</span><span style="color: #007700">[</span><span style="color: #DD0000">'description'</span><span style="color: #007700">];&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;a&nbsp;php&nbsp;manual<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$tags</span><span style="color: #007700">[</span><span style="color: #DD0000">'geo_position'</span><span style="color: #007700">];&nbsp;</span><span style="color: #FF8000">//&nbsp;49.33;-86.59<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.get-meta-tags-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Only meta tags with name attributes will be parsed.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.get-meta-tags-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.htmlentities.html" class="function" rel="rdfs-seeAlso">htmlentities()</a> - Convert all applicable characters to HTML entities</span></li>
    <li class="member"> <span class="function"><a href="function.urlencode.html" class="function" rel="rdfs-seeAlso">urlencode()</a> - URL-encodes string</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-headers.html">get_headers</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-build-query.html">http_build_query</a></div>
 <div class="up"><a href="ref.url.html">URL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>