I am trying to use PHP as a Shell scripting language.
First, I created a simple snippet of code and accessed it as a typical php file through my browser. This simple code justs echos my user id, which is stored as a $_SESSION variable. The output is "Your user id is: Tom"
Next, I tried to convert the file to a PHP script, which I can execute from the command prompt or from calls by other php files.
To do this, I just added the shebang statement:
!#/usr/local/lib/php
The script executes without errors, but now the ouput is just:
"Your user id is: "
It can't seem to access the user id variable in the $_SESSION array.
The code I am using in both cases is:
echo "Your user id is: ".$_SESSION['uid'];
Both files are the same, except that my shell script version has the shebang line added at the top.
Both files also have session_start() at the top.
I would be happy to hear if anyone has any suggestions on how I can track down the missing data contained in these variables!