I was trying to modernize my web systems and modifying some PHP files to work inside EE for better management and in the future to be able to use EE features for them.
But im really stuck because EE variables does not seems to work in PHP at all.
This works for example in a PHP tag:
$uid = '{username}';
echo $uid;Ok, so the username is displayed with PHP using echo, in the template. Very simple. Which is nice. But that is where luck ends. That is all what works, only echo. You cannot use the EE variables inside PHP.
For example I tried to load a simple XML file with PHP using the username as path like this:
$xml_document = simplexml_load_file('/home/website/'.$uid.'/file.xml');Notice that UID in this case is supposed to be the logged in EE user.
It does not work. In the first example if I change $uid to a a fixed text like “joe” it will work in the XML documenting loads.
Before EE I had the $uid being printed by another PHP system, so this code actually worked nice. Since I want to integrate this files into EE I need to be able to use the EE username authentication and features, but it seems impossible.
In Google I found someone asking exactly a similar question here:
http://stackoverflow.com/questions/6171828/expressionengine-tags-inside-php
And it seems nobody found a solution based on the replies.
If this cannot be done, then there is really no point in trying to use EE at all for my PHP files, because I could not use its variables in PHP. Would I be just better off not using PHP files with EE?
This would mean again maintaining 2 different websites, one in EE and one for PHP files which is what I wanted to avoid by centralize everything under EE. How else are people doing this? I don“t think anyone would be crazy enough to drop PHP just because they are using EE as well.
So my development is actually stopped because if I cannot even use a simple username from EE, then I did not even went to adventure as far as to try more advanced stuff.
Help would be extremely appreciated.