Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3184

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>Returns an associative array with the names of all the constants and their values</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-current-user.html">get_current_user</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.get-extension-funcs.html">get_extension_funcs</a></div>
 <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.get-defined-constants" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_defined_constants</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5)</p><p class="refpurpose"><span class="refname">get_defined_constants</span> &mdash; <span class="dc-title">Returns an associative array with the names of all the constants and their values</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.get-defined-constants-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>get_defined_constants</strong></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$categorize</code><span class="initializer"> = false</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Returns the names and values of all the constants currently defined.
   This includes those created by extensions as well as those created with
   the  <span class="function"><a href="function.define.html" class="function">define()</a></span> function.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       Causing this function to return a multi-dimensional
       array with categories in the keys of the first dimension and constants
       and their values in the second dimension.
       <div class="informalexample">
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />define</span><span style="color: #007700">(</span><span style="color: #DD0000">"MY_CONSTANT"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">get_defined_constants</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
        </div>

        <p class="para">The above example will output
something similar to:</p>
        <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [Core] =&gt; Array
        (
            [E_ERROR] =&gt; 1
            [E_WARNING] =&gt; 2
            [E_PARSE] =&gt; 4
            [E_NOTICE] =&gt; 8
            [E_CORE_ERROR] =&gt; 16
            [E_CORE_WARNING] =&gt; 32
            [E_COMPILE_ERROR] =&gt; 64
            [E_COMPILE_WARNING] =&gt; 128
            [E_USER_ERROR] =&gt; 256
            [E_USER_WARNING] =&gt; 512
            [E_USER_NOTICE] =&gt; 1024
            [E_ALL] =&gt; 2047
            [TRUE] =&gt; 1
        )

    [pcre] =&gt; Array
        (
            [PREG_PATTERN_ORDER] =&gt; 1
            [PREG_SET_ORDER] =&gt; 2
            [PREG_OFFSET_CAPTURE] =&gt; 256
            [PREG_SPLIT_NO_EMPTY] =&gt; 1
            [PREG_SPLIT_DELIM_CAPTURE] =&gt; 2
            [PREG_SPLIT_OFFSET_CAPTURE] =&gt; 4
            [PREG_GREP_INVERT] =&gt; 1
        )

    [user] =&gt; Array
        (
            [MY_CONSTANT] =&gt; 1
        )

)
</pre></div>
        </div>
       </div>
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-defined-constants-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array of constant name =&gt; constant value array, optionally
   groupped by extension name registering the constant.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.get-defined-constants-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>5.3.1</td>
       <td>
        Windows only: Core constants are categorized under <em>Core</em>,
        previously <em>mhash</em>.
       </td>
      </tr>

      <tr>
       <td>5.3.0</td>
       <td>
        Core constants are categorized under <em>Core</em>,
        previously <em>internal</em>. On Windows, the Core Constants
        are categorized under <em>mhash</em>.
       </td>
      </tr>

      <tr>
       <td>5.2.11</td>
       <td>
        The <em><code class="parameter">categorize</code></em> parameter now operates appropriately.
        Previously, the <em><code class="parameter">categorize</code></em> parameter was interpreted
        as <em>!is_null($categorize)</em>, making any value other than <strong><code>NULL</code></strong>
        force the constants to be categorized.
       </td>
      </tr>

      <tr>
       <td>5.0.0</td>
       <td>
        The <em><code class="parameter">categorize</code></em> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.get-defined-constants-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-486">
    <p><strong>Example #1  <span class="function"><strong>get_defined_constants()</strong></span> Example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">get_defined_constants</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [E_ERROR] =&gt; 1
    [E_WARNING] =&gt; 2
    [E_PARSE] =&gt; 4
    [E_NOTICE] =&gt; 8
    [E_CORE_ERROR] =&gt; 16
    [E_CORE_WARNING] =&gt; 32
    [E_COMPILE_ERROR] =&gt; 64
    [E_COMPILE_WARNING] =&gt; 128
    [E_USER_ERROR] =&gt; 256
    [E_USER_WARNING] =&gt; 512
    [E_USER_NOTICE] =&gt; 1024
    [E_ALL] =&gt; 2047
    [TRUE] =&gt; 1
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.get-defined-constants-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.defined.html" class="function" rel="rdfs-seeAlso">defined()</a> - Checks whether a given named constant exists</span></li>
    <li class="member"> <span class="function"><a href="function.get-loaded-extensions.html" class="function" rel="rdfs-seeAlso">get_loaded_extensions()</a> - Returns an array with the names of all modules compiled and loaded</span></li>
    <li class="member"> <span class="function"><a href="function.get-defined-functions.html" class="function" rel="rdfs-seeAlso">get_defined_functions()</a> - Returns an array of all defined functions</span></li>
    <li class="member"> <span class="function"><a href="function.get-defined-vars.html" class="function" rel="rdfs-seeAlso">get_defined_vars()</a> - Returns an array of all defined variables</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-current-user.html">get_current_user</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.get-extension-funcs.html">get_extension_funcs</a></div>
 <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>