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

Hard Coded

Hard coded data in code happens when a value is set as a literal in the code, and can’t be changed through any directives or parameters.

Hard-code becomes a security problem, when the hard-coded value is a password or a hash of it. This secret is now readable in the code.

<?php 

// This is hard-coded
$age = 1;

// $weight has a default value, but may also be changed at execution time
function trumpet($weight = 2) {
    echo $weight;
}

 ?>

Documentation

See Also