[TYPO3] EXT develop PHP question
R. van Twisk
typo3 at rvt.dds.nl
Mon Nov 20 14:54:36 CET 2006
Rocky Ou wrote:
> Hey,
>
> I'm quite new to PHP and TYPO3. in my pi1/class.myext.php I define an
> varible using var $usrnm=$GLOBALS['TSFE']->fe_user->user['username'];
> and this gives me an warning saying "parse error, unexpected
> T_VARIABLE". But if I put this in main function it works perfectly.
>
> Because I need to use $usrnm in several functions, It would be awesome,
> if I could define it as an global variable. Can any of you give me some
> hint on how to achieve this please?
>
> Thanks in advance!
> Rocky
>
hey Rocky,
in PHP you can define classes, and typo3 uses them massively.
If you want to us ethe variable $usrnm throughout the object
then assign the variable like this:
$this -> usrnm=$GLOBALS['TSFE']->fe_user->user['username'];
Also don't forget to check if a suer is logged in at all and if the
fe_user array was filled.
I could also strongly suggest reading up PHP, classes objects, variables and
variable scopes in PHP since this was more a PHP question then a TYPO Q.
good luck with the extension,
Ries
--
Ries van Twisk
Freelance Typo3 Developer
=== Private:
email: ries at vantwisk.nl
web: http://www.rvantwisk.nl/freelance-typo3.html
skype: callto://r.vantwisk
=== Work:
email: ries at livetravelguides.com
web: http://www.livetravelguides.com
More information about the TYPO3-english
mailing list