I am a bit confused about how to add an object to a string.
I am trying to add the $this->getUserId();
(which contains the userId of the user).
$fileName = "user_.$this->getUserId()".".$fileExt";
I am a bit confused about how to add an object to a string.
I am trying to add the $this->getUserId();
(which contains the userId of the user).
$fileName = "user_.$this->getUserId()".".$fileExt";
This should work:
$fileName = "user_{$this->getUserId()}.$fileExt";
It should give you:
user_1.ext
See the PHP manual on strings, more specifically the part about curly braces and 'complex' parsing.
For normal variables you can place them in double quoted strings and they will be parsed. For more complex things like expressions you need to wrap them in {}
so that they will be parsed.