Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dynamic

Dynamic is a common concept, and may be used in three distinct situations:

  • Dynamic call, to call a function or method whose name is in a variable
  • Dynamic constant, to call a constant whose name is in a variable
  • Dynamic property, to access a property whose name is in a variable
  • Dynamic loading, for PHP to load an extension after the start of execution
  • Dynamic variable, to access a variable whose name is in another variable.
<?php

    // Dynamic call of a variable
    $a = K;
    $x = 'a';
    echo $$x; // K
    
    const A = 1;
    $name = 'A';
    echo constant($name); // 1

?>

Documentation

See Also