How to pass function argument function to another function inside the parent function [duplicate]

    public function delete($id) {
           function getId() {
         echo $id;
    }

  }

I Want To print the parameter $id from delete() function i try to make like the above code but it shows this error Undefined variable $id