Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Language constructs are provided by the language itself (like instructions like "if", "while", ...) ; hence their name.</p> <p>One consequence of that is they are faster to be invoked than pre-defined or user-defined functions <em>(or so I've heard/read several times)</em></p> <p>I have no idea how it's done, but one thing they can do (because of being integrated directly into the langage) is "bypass" some kind of error handling mechanism. For instance, isset() can be used with non-existing variables without causing any notice, warning or error.</p> <pre><code>function test($param) {} if (test($a)) { // Notice: Undefined variable: a } if (isset($b)) { // No notice } </code></pre> <p>*Note it's not the case for the constructs of all languages.</p> <p>Another difference between functions and language constructs is that some of those can be called without parenthesis, like a keyword.</p> <p>For instance :</p> <pre><code>echo 'test'; // language construct =&gt; OK function my_function($param) {} my_function 'test'; // function =&gt; Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING </code></pre> <p><em>Here too, it's not the case for all language constructs.</em></p> <p>I suppose there is absolutely no way to "disable" a language construct because it is part of the language itself. On the other hand, lots of "built-in" PHP functions are not really built-in because they are provided by extensions such that they are always active <em>(but not all of them)</em></p> <p>Another difference is that language constructs can't be used as "function pointers" (I mean, callbacks, for instance) :</p> <pre><code>$a = array(10, 20); function test($param) {echo $param . '&lt;br /&gt;';} array_map('test', $a); // OK (function) array_map('echo', $a); // Warning: array_map() expects parameter 1 to be a valid callback, function 'echo' not found or invalid function name </code></pre> <p>I don't have any other idea coming to my mind right now... and I don't know much about the internals of PHP... So that'll be it right now ^^</p> <p>If you don't get much answers here, maybe you could ask this to the <strong>mailing-list internals</strong> (see <a href="http://www.php.net/mailing-lists.php" rel="nofollow noreferrer">http://www.php.net/mailing-lists.php</a> ), where there are many PHP core-developers ; they are the ones who would probably know about that stuff ^^</p> <p><em>(And I'm really interested by the other answers, btw ^^ )</em></p> <p>As a reference : <a href="http://php.net/manual/en/reserved.keywords.php" rel="nofollow noreferrer">list of keywords and language constructs in PHP</a></p>
 

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