i get a T_ECHO unexpected error . what is the right way of accomplishing the above task?
I don't know what you are trying to do. echo is a language construct, so returns nothing, so its return value cannot be assigned.
echo
If you want to echo a value and assign it to another variable, it is best (most legible) to do it in two statements: