title: Environment variable set by putenv() are not present while running a shell script using shell_exec() | PHP
body: <p>I have a PHP script in which I am setting a environment variable using <code>putenv()</code> and then I am calling a shell script using <code>shell_exec()</code> in this PHP script.
  In shell script I am trying to use that environment variable.</p>
  
  <p><strong>My PHP script is like:</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;?php
  ...
  ...
  putenv("USERHOME=/home/user/mnt");
  ...
  ...
  shell_exec("sudo ./script.sh arg1 arg2");
  ...
  ...
  ?&gt;
  </code></pre>
  
  <p><strong>My shell script is like:</strong></p>
  
  <pre><code>#!/bin/sh
  ...
  ...
  echo "USER HOME=" $USERHOME
  ...
  &lt;---Another use of $USERHOME-----&gt;
  ...
  exit $?
  </code></pre>
  
  <p>I am using Xampp for my application and PHP version is 5.3.8.</p>
  
  <p>Previously it was working fine on fedora core 3. 
  But recently I moved my application to CentOS 7 and now it is not working. 
  On CentOS 7, I am getting NULL value of USERHOME variable.</p>