downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/fr/function.constant.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.misc.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'fr',
  ),
 
'this' =>
  array (
   
0 => 'function.constant.php',
   
1 => 'constant',
  ),
 
'up' =>
  array (
   
0 => 'ref.misc.php',
   
1 => 'Fonctions diverses',
  ),
 
'prev' =>
  array (
   
0 => 'function.connection-timeout.php',
   
1 => 'connection_timeout',
  ),
 
'next' =>
  array (
   
0 => 'function.define.php',
   
1 => 'define',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.constant" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">constant</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">constant</span> &mdash; <span class="dc-title">Retourne la valeur d&#039;une constante</span></p>

 </div>

 <a name="function.constant.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b>constant</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$name</tt></span>
   )</div>

  <p class="simpara">
   Retourne la valeur de la constante <i><tt class="parameter">name</tt></i>
.
  </p>
  <p class="simpara">
   <b>constant()</b> est pratique lorsque vous devez lire la
   valeur d&#039;une constante, mais que vous ne connaissez son nom que durant
   l&#039;exécution du script. Par exemple, ce nom peut être le résultat
   d&#039;une fonction.
  </p>
  <p class="simpara">
   Cette fonction fonctionne également avec les
   <a href="language.oop5.constants.php" class="link">constantes de classe</a>.
  </p>
 </div>


 <a name="function.constant.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">name</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Le nom de la constante.
      </p>
     </dd>

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


 <a name="function.constant.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne la valeur de la constante, ou <b><tt class="constant">NULL</tt></b> si la constante n&#039;est pas définie.
  </p>
 </div>


 <a name="function.constant.examples"></a><div class="refsect1 examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Exemple #1 Exemple avec <b>constant()</b></b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />define</span><span style="color: #007700">(</span><span style="color: #DD0000">"MAXSIZE"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">MAXSIZE</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">constant</span><span style="color: #007700">(</span><span style="color: #DD0000">"MAXSIZE"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;identique&nbsp;à&nbsp;la&nbsp;ligne&nbsp;précédente<br /><br /><br /></span><span style="color: #007700">interface&nbsp;</span><span style="color: #0000BB">bar&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;</span><span style="color: #0000BB">test&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'foobar!'</span><span style="color: #007700">;<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;</span><span style="color: #0000BB">test&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'foobar!'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$const&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'test'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">constant</span><span style="color: #007700">(</span><span style="color: #DD0000">'bar::'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$const</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//&nbsp;string(7)&nbsp;"foobar!"<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">constant</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo::'</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$const</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//&nbsp;string(7)&nbsp;"foobar!"<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <a name="function.constant.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.define.php" class="function" rel="rdfs-seeAlso">define()</a> - Définit une constante</li>
    <li class="member"><a href="function.defined.php" class="function" rel="rdfs-seeAlso">defined()</a> - Vérifie l'existence d'une constante</li>
    <li class="member">La section sur les <a href="language.constants.php" class="link">constantes</a></li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites