 <p>Try changing</p> <pre><code>exec('gpg --homedir $path --recipient $recipient --output $encrypted_file --encrypt $plain_file --yes --always-trust', $answer, $rtn); </code></pre> <p>To</p> <pre><code>exec("gpg --homedir $path --recipient $recipient --output $encrypted_file --encrypt $plain_file --yes --always-trust", $answer, $rtn); </code></pre> <p>Notice I changed single quotes to double</p> <p><a href="http://php.net/manual/en/language.types.string.php" rel="nofollow">http://php.net/manual/en/language.types.string.php</a></p>